diff --git a/.gitignore b/.gitignore index 94e2e44..68e07e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ config.py *.in *.out +*.exe # Created by .ignore support plugin (hsz.mobi) ### Python template @@ -131,4 +132,7 @@ docs/_build/ target/ # Pycharm -venv \ No newline at end of file +venv + +# VS Code +.vscode \ No newline at end of file diff --git a/cyaron/graph.py b/cyaron/graph.py index ee6b9ff..f692dd3 100644 --- a/cyaron/graph.py +++ b/cyaron/graph.py @@ -290,7 +290,7 @@ def graph(point_count, edge_count, **kwargs): @staticmethod def DAG(point_count, edge_count, **kwargs): """DAG(point_count, edge_count, **kwargs) -> Graph - Factory method. Return a graph with point_count vertexes and edge_count edges. + Factory method. Return a directed connected graph with point_count vertexes and edge_count edges. int point_count -> the count of vertexes int edge_count -> the count of edges **kwargs(Keyword args): @@ -352,7 +352,7 @@ def DAG(point_count, edge_count, **kwargs): @staticmethod def UDAG(point_count, edge_count, **kwargs): """UDAG(point_count, edge_count, **kwargs) -> Graph - Factory method. Return a graph with point_count vertexes and edge_count edges. + Factory method. Return a undirected connected graph with point_count vertexes and edge_count edges. int point_count -> the count of vertexes int edge_count -> the count of edges **kwargs(Keyword args): @@ -402,6 +402,18 @@ def UDAG(point_count, edge_count, **kwargs): i += 1 return graph + + @staticmethod + def connected(point_count, edge_count, directed=False, **kwargs): + """connected(point_count, edge_count, **kwargs) -> Graph + Factory method. Return a connected graph with point_count vertexes + int point_count -> the count of vertexes + bool directed -> whether the graph is directed + """ + if directed: + return Graph.DAG(point_count, edge_count, **kwargs) + else: + return Graph.UDAG(point_count, edge_count, **kwargs) @staticmethod def hack_spfa(point_count, **kwargs):