Commit c804ff8e authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Add load_graph utility function

Avoids having to do

    g = Graph()
    g.load("foo")

each time. Now one can do simply,

    g = load_graph("foo")

Fantastic.
parent ecabb934
......@@ -39,8 +39,8 @@ __URL__="http://graph-tool.forked.de"
from . core import __version__, Graph, GraphError, Vector_bool, \
Vector_int32_t, Vector_int64_t, Vector_double, Vector_long_double,\
Vector_string, value_types
Vector_string, value_types, load_graph
__all__ = ["Graph", "GraphError", "Vector_bool", "Vector_int32_t",
"Vector_int64_t", "Vector_double", "Vector_long_double",
"Vector_string", "value_types"]
"Vector_string", "value_types", "load_graph"]
......@@ -671,6 +671,12 @@ class Graph(object):
self.set_edge_filter(state["edge_filt"][0],
state["edge_filt"][1])
def load_graph(filename, format="auto"):
"""Load a graph from file"""
g = Graph()
g.load(filename, format=format)
return g
def value_types():
"""Return a list of possible properties value types"""
return libcore.get_property_types()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment