src.dackar.knowledge_graph.pygds ================================ .. py:module:: src.dackar.knowledge_graph.pygds .. autoapi-nested-parse:: Created on March 20, 2025 @author: wangc, mandd Attributes ---------- .. autoapisummary:: src.dackar.knowledge_graph.pygds.logger Classes ------- .. autoapisummary:: src.dackar.knowledge_graph.pygds.PyGDS Module Contents --------------- .. py:data:: logger .. py:class:: PyGDS(uri, user, pwd, database='neo4j') .. py:attribute:: __uri .. py:attribute:: __user .. py:attribute:: __pwd .. py:attribute:: __driver :value: None .. py:attribute:: __database :value: 'neo4j' .. py:attribute:: __graph :value: [] .. py:method:: close() Close the python neo4j GDS connection .. py:method:: restart() Restart the python neo4j GDS connection .. py:method:: query(query, params=None, database=None) User provided Cypher query statements for python neo4j driver to use to query database :param query: user provided Cypher query statements :type query: str :param parameters: dictionary that provide key/value pairs for query statement to use. Defaults to None. :type parameters: dict, optional :param db: name for database. Defaults to None. :type db: str, optional :returns: returned queried results. :rtype: DataFrame .. py:method:: project(graph_name, node_spec, relationship_spec) Creates a named graph in the catalog for use by algorithms :param graph_name: graph name :type graph_name: str :param node_spec: Node project, dict option ({nodeLabel: {'properties':[properties]}}) :type node_spec: str or dict :param relationship_spec: Relationship projection, dict option ({relationLabel: {'properties':[properties]}}) :type relationship_spec: str or dict :returns: GDS graph object result (pandas.Series): containing metadata from underlying procedure call. :rtype: graph (Graph object) .. py:method:: load_dataframe(graph_name, nodes, relationships, write=False) Constructing a graph from pandas.DataFrames :param graph_name: Name of the graph to be constructed :type graph_name: str :param nodes: one or more dataframes containing node data :type nodes: pandas.DataFrame :param relationships: one or more dataframes containing relationship data :type relationships: pandas.DataFrame :returns: GDS graph object :rtype: graph (Graph object) .. rubric:: Examples nodes = pandas.DataFrame( { "nodeId": [0, 1, 2, 3], "labels": ["A", "B", "C", "A"], "prop1": [42, 1337, 8, 0], "otherProperty": [0.1, 0.2, 0.3, 0.4] } ) relationships = pandas.DataFrame( { "sourceNodeId": [0, 1, 2, 3], "targetNodeId": [1, 2, 3, 0], "relationshipType": ["REL", "REL", "REL", "REL"], "weight": [0.0, 0.0, 0.1, 42.0] } ) .. py:method:: check() Print the graph information .. py:method:: reset() Reset the GDS, delete the graph in the memory .. py:method:: centrality(method='eigenvector', check=False) Centrality algorithms are used to understand the role or influence of particular nodes in a graph :param method: centrality algorithm. Defaults to 'eigenvector'. :type method: str, optional :param 'Engenvector centrality' measures the importance or influence of a node based on its connections: :param to other nodes in the network.: :param 'Betweenness centrality' quantifies the importance of a node as a bridge or intermediary: :param in the network. It measures how often a node lies on the shortest path between other pairs of nodes: :param 'Degree centrality' measures the number of connections: :type 'Degree centrality' measures the number of connections: edges :param check: print graph information if True :type check: bool, optional