darabos commited on
Commit
4bd97bb
·
1 Parent(s): 33289cb

Support isolated nodes in graph sampling.

Browse files
lynxkite-graph-analytics/src/lynxkite_plugins/graph_analytics/lynxkite_ops.py CHANGED
@@ -73,11 +73,14 @@ class Bundle:
73
 
74
  def to_nx(self):
75
  # TODO: Use relations.
76
- graph = nx.from_pandas_edgelist(self.dfs["edges"])
77
  if "nodes" in self.dfs:
78
- nx.set_node_attributes(
79
- graph, self.dfs["nodes"].set_index("id").to_dict("index")
80
  )
 
 
 
81
  return graph
82
 
83
  def copy(self):
 
73
 
74
  def to_nx(self):
75
  # TODO: Use relations.
76
+ graph = nx.DiGraph()
77
  if "nodes" in self.dfs:
78
+ graph.add_nodes_from(
79
+ self.dfs["nodes"].set_index("id").to_dict("index").items()
80
  )
81
+ graph.add_edges_from(
82
+ self.dfs["edges"][["source", "target"]].itertuples(index=False, name=None)
83
+ )
84
  return graph
85
 
86
  def copy(self):