示例#1
0
文件: g500.py 项目: harperj/BSPGraph
    def initialize(self, filename):
        edge_list = loader.readInEdgesASCII(filename)
        if edge_list == False:
            raise Exception("Invalid or non-existant file.")
        self.build_graph_from_edge_list(edge_list)

        self.target_id = self.pick_target()
示例#2
0
    def test_initialize (self):
        test_graph = BFSGraph(256, BFSNode)
        test_graph.initialize("tests/data/4")
        edge_list = loader.readInEdgesASCII("tests/data/4")
        reverse_edges = []

        #Add the reverse of edges since these are undirected
        for edge in edge_list:
            reverse_edges.append((edge[1], edge[0]))
        for reversed_edge in reverse_edges:
            edge_list.append(reversed_edge)

        for node in test_graph.nodes:
            for edge in node.edges:
                tuple_edge = (edge.start_id, edge.end_id)
                self.assertIn(tuple_edge, edge_list)