Neo4jGraph
Neo4j https://neo4j.com/docs/getting-started
This module referred to the work of Langchian and Llamaindex.
Parameters:
- url (str): The URL of the Neo4j database server.
- username (str): The username for database authentication.
- password (str): The password for database authentication.
- database (str): The name of the database to connect to. Defaults to
neo4j
. - timeout (Optional[float]): The timeout for transactions in seconds. Useful for terminating long-running queries. Defaults to
None
. - truncate (bool): A flag to indicate whether to remove lists with more than
LIST_LIMIT
elements from results. Defaults toFalse
.
init
get_client
get_schema
- refresh (bool): A flag indicating whether to forcibly refresh the schema from the Neo4jGraph store regardless of whether it is already cached. Defaults to
False
.
get_structured_schema
_value_truncate
LIST_LIMIT
elements. This method aims to reduce unnecessary
computational cost and noise in scenarios where such detailed data
structures are not needed. If the input value is not dictionary or
list then give the raw value back.
Parameters:
- raw_value (Any): The raw value to be truncated.
query
- query (str): The Cypher query to be executed.
- params (Optional[Dict[str, Any]]): A dictionary of parameters to be used in the query. Defaults to
None
.
refresh_schema
add_triplet
- subj (str): The identifier for the subject entity.
- obj (str): The identifier for the object entity.
- rel (str): The relationship between the subject and object.
- timestamp (Optional[str]): The timestamp of the relationship. Defaults to None.
_delete_rel
- subj (str): The identifier for the subject entity.
- obj (str): The identifier for the object entity.
- rel (str): The relationship between the subject and object to delete.
_delete_entity
- entity (str): The unique identifier of the entity to be deleted.
_check_edges
- entity (str): The unique identifier of the entity to check.
delete_triplet
- subj (str): The identifier for the subject entity.
- obj (str): The identifier for the object entity.
- rel (str): The relationship between the subject and object.
_get_node_import_query
- base_entity_label (bool): Flag indicating whether to use a base entity label in the MERGE operation.
- include_source (bool): Flag indicating whether to include source element information in the query.
_get_rel_import_query
- base_entity_label (bool): Flag indicating whether to use a base entity label in the MERGE operation.
add_graph_elements
- graph_elements (List[GraphElement]): A list of GraphElement objects that contain the nodes and relationships to be added to the graph. Each GraphElement should encapsulate the structure of part of the graph, including nodes, relationships, and the source element information.
- include_source (bool, optional): If True, stores the source element and links it to nodes in the graph using the MENTIONS relationship. This is useful for tracing back the origin of data. Merges source elements based on the
id
property from the source element metadata if available; otherwise it calculates the MD5 hash ofpage_content
for merging process. Defaults toFalse
. - base_entity_label (bool, optional): If True, each newly created node gets a secondary
BASE_ENTITY_LABEL
label, which is indexed and improves import speed and performance. Defaults toFalse
.
random_walk_with_restarts
- graph_name (str): The name of the original graph in the graph catalog.
- sampling_ratio (float): The fraction of nodes in the original graph to be sampled.
- start_node_ids (List[int]): IDs of the initial set of nodes of the original graph from which the sampling random walks will start.
- restart_probability (float, optional): The probability that a sampling random walk restarts from one of the start nodes. Defaults to
0.1
. - node_label_stratification (bool, optional): If true, preserves the node label distribution of the original graph. Defaults to
False
. - relationship_weight_property (Optional[str], optional): Name of the relationship property to use as weights. If unspecified, the algorithm runs unweighted. Defaults to
None
.
common_neighbour_aware_random_walk
- graph_name (str): The name of the original graph in the graph catalog.
- sampling_ratio (float): The fraction of nodes in the original graph to be sampled.
- start_node_ids (List[int]): IDs of the initial set of nodes of the original graph from which the sampling random walks will start.
- node_label_stratification (bool, optional): If true, preserves the node label distribution of the original graph. Defaults to
False
. - relationship_weight_property (Optional[str], optional): Name of the relationship property to use as weights. If unspecified, the algorithm runs unweighted. Defaults to
None
.
get_triplet
- subj (Optional[str]): The ID of the subject node. If None, matches any subject node. (default: :obj:
None
) - obj (Optional[str]): The ID of the object node. If None, matches any object node. (default: :obj:
None
) - rel (Optional[str]): The type of relationship. If None, matches any relationship type. (default: :obj:
None
)