src/cypher/run.py
def get_graph(self, directed=True):
        """Returns a NetworkX multi-graph instance built from the result set

        :param directed: boolean, optional (default=`True`).
            Whether to create a direted or an undirected graph.
        """
        if nx is None:
            raise ImportError("Try installing NetworkX first.")
        if directed:
            graph = nx.MultiDiGraph()
        else:
            graph = nx.MultiGraph()
        for item in self._results.graph:
            for node in item['nodes']:
                properties = copy.deepcopy(node['properties'])
                properties['labels'] = node['labels']
                graph.add_node(node['id'], **properties)
            for rel in item['relationships']:
                properties = copy.deepcopy(rel['properties'])
                properties.update(
                    id=rel['id'],
                    type=rel['type']
                )
                graph.add_edge(rel['startNode'], rel['endNode'],
                               key=rel.get('type'), **properties)
        return graph
def get_graph(self, directed=True):
        if nx is None:
            raise ImportError("Try installing NetworkX first.")
        if directed:
            graph = nx.MultiDiGraph()
        else:
            graph = nx.MultiGraph()
        for item in self._results.graph:
            for node in item['nodes']:
                properties = copy.deepcopy(node['properties'])
                properties['labels'] = node['labels']
                graph.add_node(node['id'], **properties)
            for rel in item['relationships']:
                properties = copy.deepcopy(rel['properties'])
                properties.update(
                    id=rel['id'],
                    type=rel['type']
                )
                graph.add_edge(rel['startNode'], rel['endNode'],
                               key=rel.get('type'), **properties)
        return graph
def get_graph ( self , directed = True ) : if nx is None : raise ImportError ( "Try installing NetworkX first." ) if directed : graph = nx . MultiDiGraph ( ) else : graph = nx . MultiGraph ( ) for item in self . _results . graph : for node in item [ 'nodes' ] : properties = copy . deepcopy ( node [ 'properties' ] ) properties [ 'labels' ] = node [ 'labels' ] graph . add_node ( node [ 'id' ] , * * properties ) for rel in item [ 'relationships' ] : properties = copy . deepcopy ( rel [ 'properties' ] ) properties . update ( id = rel [ 'id' ] , type = rel [ 'type' ] ) graph . add_edge ( rel [ 'startNode' ] , rel [ 'endNode' ] , key = rel . get ( 'type' ) , * * properties ) return graph
Returns a NetworkX multi-graph instance built from the result set

        :param directed: boolean, optional (default=`True`).
            Whether to create a direted or an undirected graph.
Returns a NetworkX multi - graph instance built from the result set