Files
School/Anul 1/Semestrul 2/Graph Algo/Seminar/2/graph.py
T
2024-08-31 12:07:21 +03:00

41 lines
857 B
Python

class Graph:
def __init__(self,n:int):
'''
Constructs a graph with n vertices numbered from 0 to n-1 and no edges.
'''
pass
def addEdge(self,x,y):
'''
Adds an edge from x to y. Returns True on success, False if the edge already exists. Precond: x and y exists
'''
pass
def parseX(self):
pass
def parseNOut(self,x):
pass
def parseNIn(self,x):
pass
def isEdge(self,x,y):
pass
def print_graph(g:Graph):
print("Outbound")
for x in g.parseX():
print(x,":",end="")
for y in g.parseNOut(x):
print(y," ",end="")
print()
def create_small_graph():
g=Graph(3)
for e in [(0,0),(0,1),(0.2)]:
g.addEdge(e[0],e[1])
return g
def main():
g=create_small_graph()
print_graph(g)