google / guava

Google core libraries for Java
Apache License 2.0
50.28k stars 10.92k forks source link

Graph collectors? #3754

Open oliviercailloux opened 4 years ago

oliviercailloux commented 4 years ago

Are there collectors that create and populate graphs, that I perhaps have missed? For example, can I easily stream the entries of a Map<K, K> and return a (say, directed) graph that would contain the corresponding edges?

If so, please document on the wiki.

If not, please consider adding a set of nice collectors, similar to those available for the guava collection classes!

cpovirk commented 4 years ago

We have nothing. This does sound like something we ought to have. Thanks.

mitchellirvin commented 4 years ago

@cpovirk do you have a preference for which of the Graph types have collectors implemented or whether they're implemented in one PR or their own?

I'm initially thinking to start with adding graph/GraphCollectors and defining a basic collector for ImmutableGraph and moving forward from there.

Would you mind providing some guidance on any considerations you might have? I'm new to the codebase, definitely not sure of where the blindspots I have are yet.

cpovirk commented 4 years ago

Unfortunately, I know very little about common.graph. One of its owners will have to have a look eventually, but I wouldn't expect that to happen soon :(

oliviercailloux commented 4 years ago

Related: Build Graph given a SuccessorsFunction and a set of nodes.