Skip to content

Commit 84c89d3

Browse files
committed
šŸ› Fix(report.py): Allow loading networks from edgelist without attributes. There was an error before if a network without attributes was passed.
1 parent c334dea commit 84c89d3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ā€Žvuegen/report.pyā€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@ def read_network(self) -> nx.Graph:
204204
edge_attributes = [col for col in df_net.columns if col not in required_columns]
205205

206206
# Return a NetworkX graph object from the edgelist
207-
G = nx.from_pandas_edgelist(df_net, source="source", target="target", edge_attr=edge_attributes)
207+
if edge_attributes:
208+
G = nx.from_pandas_edgelist(df_net, source="source", target="target", edge_attr=edge_attributes)
209+
else:
210+
G = nx.from_pandas_edgelist(df_net, source="source", target="target")
211+
208212
self.logger.info(f"Successfully read network from file: {self.file_path}.")
209213
return G
210214
elif self.csv_network_format == CSVNetworkFormat.ADJLIST:

0 commit comments

Comments
Ā (0)