diff --git a/exam_template/python/Graph.py b/exam_template/python/Graph.py index 4f9647c..341c70a 100644 --- a/exam_template/python/Graph.py +++ b/exam_template/python/Graph.py @@ -2,7 +2,7 @@ from sys import argv from pathlib import Path from math import sin, cos, pi -from common import printc, replaceContent +from common import printc, printerr, replaceContent class Matrix: """ Adjacency matrix which supports 0 and 1 """ @@ -127,6 +127,10 @@ class Graph: edges = [] connected_subgraphs = [set(v) for v in self.nodes] + if not all(n in ''.join(x+y for x,y in self.edges) for n in self.nodes): + printerr('Not all nodes are connected. There is no spanning tree to be made') + return + def find_subgraph_containing(v): return [x for x in connected_subgraphs if v in x][0]