Skip to content

Commit

Permalink
fix event loop conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
wiltshirek committed Nov 6, 2024
1 parent a73ef6e commit ac0b7fd
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 152 deletions.
28 changes: 17 additions & 11 deletions get_all_edges_nx.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
import networkx as nx

G = nx.read_graphml('./dickensTestEmbedcall/graph_chunk_entity_relation.graphml')
G = nx.read_graphml("./dickensTestEmbedcall/graph_chunk_entity_relation.graphml")


def get_all_edges_and_nodes(G):
# Get all edges and their properties
edges_with_properties = []
for u, v, data in G.edges(data=True):
edges_with_properties.append({
'start': u,
'end': v,
'label': data.get('label', ''), # Assuming 'label' is used for edge type
'properties': data,
'start_node_properties': G.nodes[u],
'end_node_properties': G.nodes[v]
})
edges_with_properties.append(
{
"start": u,
"end": v,
"label": data.get(
"label", ""
), # Assuming 'label' is used for edge type
"properties": data,
"start_node_properties": G.nodes[u],
"end_node_properties": G.nodes[v],
}
)

return edges_with_properties


# Example usage
if __name__ == "__main__":
# Assume G is your NetworkX graph loaded from Neo4j

all_edges = get_all_edges_and_nodes(G)

# Print all edges and node properties
for edge in all_edges:
print(f"Edge Label: {edge['label']}")
Expand All @@ -31,4 +37,4 @@ def get_all_edges_and_nodes(G):
print(f"Start Node Properties: {edge['start_node_properties']}")
print(f"End Node: {edge['end']}")
print(f"End Node Properties: {edge['end_node_properties']}")
print("---")
print("---")
Loading

0 comments on commit ac0b7fd

Please sign in to comment.