Open yecol opened 2 years ago
Compare to NetworkX
API:
g.get_edges
is similar to g.edges
to get edges of g
g.edges
return a view of edges;g.edges
not support Label;g.edges
accept bunch of nodes to only get edges of these nodes;g.edges
support looks up operation like g.edges[u, v];I think we can unify the get_edges
and g.edges
of NetworkX, since label can be ignored in NetworkX Graph, And we can return view in gs graph too with fetch only when use
strategy.
g.get_vertices
is similar to g.nodes
to get vertices of g
Similar to g.edges
g.subgraph
is similar to g.subgraph
of NetworkX to create subgraph of g
BTW, I suggest we can provide an api like g.neighbors(v)
or g.adj(v)
to get the neighbors of vertex, since this is a natural way to iterate edges in algorithm.
g.neighbor(v, Label=None, data=None)
# return neighbors nodes of v (can select certain edge label neighbors and fetch edge data or not)
g.successors(v, Label=None, data=None)
# return successors nodes of v
g.predecessors(v, Label=None, data=None)
# return predecessors nodes of v
Thanks @acezen , revised the proposal based on your comments.
g_apply
I suggest we can split subgraph
to subgraph
and edge_subgraph
for clarifying the semantic
subgraph
for induce vertices subgraph
g4 = g.subgraph(vertices={"L1":{"P1":"value1", "P2":"value2"}})
g5 = g.subgraph(vertices={"L1":fn})
2. `edge_subgraph` for induce edges subgraph
```python
g4 = g.edge_subgraph(edges={"L1":{"P1":"value1", "P2":"value2"}})
# fn is a lambda func, take a edges as parameter, true/false as return;
g5 = g.edge_subgraph(edges={"L1":fn})
in the original graph g
, exists edges:
v1--e1-->v2;
v3--e2-->v2;
fn
applied on edges will lead to conflicts on v2
;
Proposal
get edges/vertices as dataframe
graph filtering, generate a new (property) graph
graph transformation