Skip to content

[FEA] pipe #239

Description

@lmeyerov

Is your feature request related to a problem? Please describe.

It'd be super convenient to have a graph-friendly pipeline operator, replacing a(b(c(g))) with g.pipe(c).pipe(b).pipe(a), similar to pandas and other ~monadic envs

Describe the solution you'd like

It should support transforms over nodes, edges, and graphs

Ex:

g.pipe(graph=lambda g: g.bind(x='x'))
g.pipe(lambda g: g.bind(x='x')) # shorthand

g.pipe(edges=lambda g: g._edges[['src', 'dst']]) # g in, df out
g.edges(lambda g: g._edges[['src', 'dst']]) # shorthand

g.pipe(nodes=lambda g: g._nodes[['node']]) # g in, df out
g.nodes(lambda g: g._nodes[['node']]) # shorthand
  • It should be allowed to provide both nodes=, edges=
  • If both nodes= / edges= and graph= kwargs are provided, run them in the provided order:
g.pipe(nodes=fn_1, edges=fn_2, graph=fn_3)
g.pipe(graph=fn_1, nodes=fn_2, edges=fn_3)

Describe alternatives you've considered
While we do have g.edges(df) / g.nodes(df), they do not support flows like g.cypher(...).edges(clean_fn)

Additional context

  • Similar to pandas pipe
  • Most composition operators get inherited from here as they're table level
  • ... Except we still don't have graph-level composition: union, subtract, ...

Activity

  1. lmeyerov commented on Aug 24, 2021

    @lmeyerov
    ContributorAuthor

    Implemented in 0.19.0 as g.pipe(lambda g: new_g(g)), g.edges(lambda g: new_e_df(g)), and g.nodes(lambda g: new_n_df(g))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions