-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxgraph.py
More file actions
25 lines (21 loc) · 854 Bytes
/
xgraph.py
File metadata and controls
25 lines (21 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from graph.base import *
import os
class UndirectedGraph(GraphAdj):
def addEdge(self, sindex, dindex, weight):
#super(UndirectedGraph, self).addEdge(self, sindex, dindex, weight)
edge = GraphAdj.addEdge(self, sindex, dindex, weight)
self.getVEntry(edge['source']).edges.append(edge)
self.getVEntry(edge['dest']).edges.append(edge.reverse())
return edge
class DirectedGraph(GraphAdj):
def addEdge(self, sindex, dindex, weight):
#super(DirectedGraph, self).addEdge(self, sindex, dindex, weight)
edge = GraphAdj.addEdge(self, sindex, dindex, weight)
self.getVEntry(edge['source']).edges.append(edge)
return edge
if __name__ == '__main__':
conf = os.getcwd() + '/conf/graph0.txt'
G = DirectedGraph(conf)
G.output()
G1 = UndirectedGraph(conf)
G1.output()