@@ -304,7 +304,7 @@ def graph(point_count, edge_count, **kwargs):
304304 @staticmethod
305305 def DAG (point_count , edge_count , ** kwargs ):
306306 """DAG(point_count, edge_count, **kwargs) -> Graph
307- Factory method. Return a graph with point_count vertexes and edge_count edges.
307+ Factory method. Return a directed connected graph with point_count vertexes and edge_count edges.
308308 int point_count -> the count of vertexes
309309 int edge_count -> the count of edges
310310 **kwargs(Keyword args):
@@ -371,7 +371,7 @@ def DAG(point_count, edge_count, **kwargs):
371371 @staticmethod
372372 def UDAG (point_count , edge_count , ** kwargs ):
373373 """UDAG(point_count, edge_count, **kwargs) -> Graph
374- Factory method. Return a graph with point_count vertexes and edge_count edges.
374+ Factory method. Return a undirected connected graph with point_count vertexes and edge_count edges.
375375 int point_count -> the count of vertexes
376376 int edge_count -> the count of edges
377377 **kwargs(Keyword args):
@@ -426,6 +426,18 @@ def UDAG(point_count, edge_count, **kwargs):
426426 i += 1
427427
428428 return graph
429+
430+ @staticmethod
431+ def connected (point_count , edge_count , directed = False , ** kwargs ):
432+ """connected(point_count, edge_count, **kwargs) -> Graph
433+ Factory method. Return a connected graph with point_count vertexes
434+ int point_count -> the count of vertexes
435+ bool directed -> whether the graph is directed
436+ """
437+ if directed :
438+ return Graph .DAG (point_count , edge_count , ** kwargs )
439+ else :
440+ return Graph .UDAG (point_count , edge_count , ** kwargs )
429441
430442 @staticmethod
431443 def hack_spfa (point_count , ** kwargs ):
0 commit comments