kevinrutherford / dag

Directed acyclic graphs for Ruby
43 stars 7 forks source link

Subgraph query #2

Closed dstuebe closed 9 years ago

dstuebe commented 9 years ago

@kevinrutherford Please consider this addition to the DAG library.

Define a method which will create a new graph from a subset of vertices. Since the vertex object has a reference the graph that it belongs to, the subgraph and its vertices must be new objects. Specify the interface to select the subgraph using successors and predecessors.

kevinrutherford commented 9 years ago

This is a nice idea. There is a lot of duplication in that subgraph method -- can any of it be removed by extracting some methods?

dstuebe commented 9 years ago

Yes - I can dry that up a lot, but I wanted your thoughts on the approach. Is there an easier way than creating those temporary mappings between the old graph and the new one?

Since the dag belongs to the vertex rather than the other way around, I can't think of a better way to do it.

Glad you are interested and I will try and clean it up this week.

dstuebe commented 9 years ago

Thanks Kevin - I will make a PR to dry up the subgraph method this weekend. Thanks for your help.