(cls, g)
return graph
Converts the graph from graph-tool

        @param g: graph-tool Graph
Converts the graph from graph-tool
Converts the graph from graph - tool
def from_graph_tool(cls, g):
        """Converts the graph from graph-tool

        @param g: graph-tool Graph
        """
        # Graph attributes
        gattr = dict(g.graph_properties)

        # Nodes
        vcount = g.num_vertices()

        # Graph
        graph = cls(n=vcount, directed=g.is_directed(), graph_attrs=gattr)

        # Node attributes
        for key, val in g.vertex_properties.items():
            prop = val.get_array()
            for i in range(vcount):
                graph.vs[i][key] = prop[i]

        # Edges and edge attributes
        # NOTE: graph-tool is quite strongly typed, so each property is always
        # defined for all edges, using default values for the type. E.g. for a
        # string property/attribute the missing edges get an empty string.
        edges = []
        eattr_names = list(g.edge_properties)
        eattr = {name: [] for name in eattr_names}
        for e in g.edges():
            edges.append((int(e.source()), int(e.target())))
            for name, attr_map in g.edge_properties.items():
                eattr[name].append(attr_map[e])

        graph.add_edges(edges, eattr)

        return graph
def from_graph_tool ( cls , g ) : # Graph attributes gattr = dict ( g . graph_properties ) # Nodes vcount = g . num_vertices ( ) # Graph graph = cls ( n = vcount , directed = g . is_directed ( ) , graph_attrs = gattr ) # Node attributes for key , val in g . vertex_properties . items ( ) : prop = val . get_array ( ) for i in range ( vcount ) : graph . vs [ i ] [ key ] = prop [ i ] # Edges and edge attributes # NOTE: graph-tool is quite strongly typed, so each property is always # defined for all edges, using default values for the type. E.g. for a # string property/attribute the missing edges get an empty string. edges = [ ] eattr_names = list ( g . edge_properties ) eattr = { name : [ ] for name in eattr_names } for e in g . edges ( ) : edges . append ( ( int ( e . source ( ) ) , int ( e . target ( ) ) ) ) for name , attr_map in g . edge_properties . items ( ) : eattr [ name ] . append ( attr_map [ e ] ) graph . add_edges ( edges , eattr ) return graph