fcs.server.graph_db

This module describes API for graph database, used by GraphAndBTreeDB in fcs.server.link_db.

class GraphDB(location)

Class provides easy access to Neo4j database.

Parameters:location (string) – Location of database.
graph

Reference to database.

is_in_base(link)

Checks if the given link is already in database.

Parameters:link (string) – Searched link.
Returns:Information if the link is in database.
Return type:bool

Changes link priority.

Parameters:
  • link (string) – URL with priority modified.
  • priority (int) – Link’s new priority.
Returns:

Link’s old priority.

Return type:

int

get_details(link)

Returns information stored in database about specified link.

Parameters:link (string) – URL with priority modified.
Returns:List with 3 strings - priority, fetch date(could be empty string) and depth.
Return type:list
Raises Exception:
 if link has not been found in databse

Adds given link to database.

Parameters:
  • link (string) – URL to add.
  • priority (int) – Link priority.
  • depth (int) – Link depth.
Returns:

Object representing new node in database.

Return type:

neo4j.Nodes if successful, None otherwise

set_as_fetched(link)

Sets time of page processing ending.

Parameters:link (string) – URL.
points(url_a, url_b)

Connects two URLs-representing nodes in graph with relationship: “url_b obtained from page identified with url_a”.

Parameters:
  • url_a (string) – First URL.
  • url_b (string) – Second URL.
Returns:

Object representing edge between nodes representing url_a and url_b.

Return type:

neo4j.Relationships

get_connected(links)

Provides list of URLs which can be extracted from specified pages.

Parameters:links (list) – List of strings representing URLs.
Returns:List of URLs (as strings).
Return type:list
clear()

Clears database instance.