code: def _construct_graph_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():
          # val.get_array() returns None for non-scalar types so use the slower
          # way if this happens
          prop = val.get_array()
          arr = prop if prop is not None else val
          for i in range(vcount):
              graph.vs[i][key] = arr[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
  
label_desc: Use image node_id 4 for calling a global function with example usage: _construct_graph_from_graph_tool(cls, g) and returns: graph