Esempio n. 1
0
    def load_all_edges(self):
        print("MemoryGraph: loading graph")
        start = MemoryGraph.edge_key((0,0))
        stop = MemoryGraph.edge_key((MAX_KEY_VALUE, MAX_KEY_VALUE))

        for b in self.db.iterator(start=start, stop=stop, include_value=False):
            from_node_id = struct.unpack_from('>Q', b, offset=1)[0]
            to_node_id = struct.unpack_from('>Q', b, offset=9)[0]
            cwg.add_edge(self.graph, from_node_id, to_node_id)
Esempio n. 2
0
 def insert_adjacencies(self, edges):
     edges = [e for e in edges if e[0] != e[1]]
     self.save_edges(edges)
     for e in edges:
         cwg.add_edge(self.graph, e[0], e[1])
Esempio n. 3
0
 def insert_adjacency(self, from_id, to_id):
     if(from_id == to_id): return
     self.save_edges([(from_id, to_id)])
     cwg.add_edge(self.graph, from_id, to_id)
Esempio n. 4
0
import community_walk_graph as cwg

graph = cwg.new_graph()
cwg.add_edge(graph, 1, 2)
cwg.add_edge(graph, 2, 3)
cwg.add_edge(graph, 3, 4)
cwg.add_edge(graph, 4, 5)
cwg.add_edge(graph, 5, 6)
cwg.add_edge(graph, 6, 7)
cwg.add_edge(graph, 7, 8)
cwg.add_edge(graph, 8, 9)
cwg.add_edge(graph, 9, 10)
cwg.add_edge(graph, 10, 11)
cwg.add_edge(graph, 11, 12)
cwg.add_edge(graph, 12, 13)
cwg.add_edge(graph, 13, 14)
cwg.add_edge(graph, 14, 15)
cwg.add_edge(graph, 15, 16)
cwg.add_edge(graph, 16, 17)
cwg.add_edge(graph, 17, 18)
cwg.add_edge(graph, 18, 19)
cwg.add_edge(graph, 19, 20)
cwg.add_edge(graph, 20, 1)

communities_result = cwg.communities(graph,
                                     [1, 2, 3, 4, 5, 11, 12, 13, 14, 15], 7,
                                     100, 50)
print(communities_result)