graph api in guava 20.0 does not include edge as an object

308 views
Skip to first unread message

akash77...@gmail.com

unread,
Nov 20, 2016, 5:53:04 AM11/20/16
to guava-discuss, Arvind Das, Ankit Oodles, shashikant sharma
Hi

I want to suggest a feature request for guava api.
graph api in guava 20.0 does not include edges as a concrete object.

Set<EndpointPair<N>> edges();

public abstract class EndpointPair<N> implements Iterable<N> {
  private final N nodeU;
  private final N nodeV;
  ....
}

As you can see, edge in a graph is an EndpointPair of two nodes. Internal data structure for this edge contains start node and end node, but it does not include a relationship edge b/w the two nodes.

They are many scenarios where we need relation b/w two nodes.
For example , If you want to create a graph of connected cities then you must include distance b/w any two cities.
Another example would be graph b/w people who borrowed money from each other.

I have implemented this kind of graph in which , edge contains the information for two nodes and their relationship.
My implementation has many bugs , but just wanted to show you the type of improvement that can be done in guava api.

Thanks
Akash Sharma

David Beaumont

unread,
Nov 20, 2016, 7:25:03 AM11/20/16
to akash77...@gmail.com, guava-discuss, Arvind Das, Ankit Oodles, shashikant sharma
Doesn't ValueGraph do what you want?

David

--
guava-...@googlegroups.com
Project site: https://github.com/google/guava
This group: http://groups.google.com/group/guava-discuss
 
This list is for general discussion.
To report an issue: https://github.com/google/guava/issues/new
To get help: http://stackoverflow.com/questions/ask?tags=guava
---
You received this message because you are subscribed to the Google Groups "guava-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/d5015365-dcc1-4066-8d60-ac534e1f2538%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
David Beaumont :: Îñţérñåţîöñåļîžåţîờñ Libraries :: Google
Google Switzerland GmbH., Brandschenkestrasse 110, CH-8002, Zürich - Switzerland

jase...@google.com

unread,
Nov 20, 2016, 3:35:32 PM11/20/16
to guava-discuss, akash77...@gmail.com, arvin...@hotmail.com, ankey...@gmail.com, sharma.sh...@gmail.com
Yes, it sounds like ValueGraph is what you're looking for. You can find more information here:

To unsubscribe from this group and stop receiving emails from it, send an email to guava-discus...@googlegroups.com.

Joshua O'Madadhain

unread,
Nov 21, 2016, 10:18:56 AM11/21/16
to James Sexton, guava-discuss, akash77...@gmail.com, arvin...@hotmail.com, ankey...@gmail.com, sharma.sh...@gmail.com
The user guide has a section that talks about the three different graph types (Graph, ValueGraph, Network) and how to tell which of these that you want:

It sounds like you either want ValueGraph or Network, depending on what you need to do with your edge objects; that resource should help you figure it out.

To unsubscribe from this group and stop receiving emails from it, send an email to guava-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/78154e2d-39ea-478f-beb5-240d2e18b9fc%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
   Joshua O'Madadhain: Information Scientist, Musician, Philosopher-At-Tall
  "It's that moment of dawning comprehension that I live for" -- Bill Watterson

akash77...@gmail.com

unread,
Nov 22, 2016, 1:53:08 AM11/22/16
to guava-discuss, jase...@google.com, akash77...@gmail.com, arvin...@hotmail.com, ankey...@gmail.com, sharma.sh...@gmail.com
Thanks.
This is what I was looking for.
Actually I am trying to learn graphs and was searching for a java api on it.Found yours and trying to learn more things.

One thing I wanted to raise against this design is , the Network interface ,
interface Network<N, E>

could be better if 
interface Network<N, E extends Comparable<E>>

If I am not wrong here, the edges must be comparable so that it can helpful while sorting for example in minimum spanning tree.

Also I have one more doubt regarding the api. Does this api implemented any algo of BFS or DFS or any applications of them.

Also can you please provide the timing when its (20.0) Beta phase will be completed and will be ready to use for any production application.

Kurt Alfred Kluever

unread,
Nov 22, 2016, 2:36:58 AM11/22/16
to akash77...@gmail.com, guava-discuss, James Sexton, arvin...@hotmail.com, ankey...@gmail.com, sharma.sh...@gmail.com
On Tue, Nov 22, 2016 at 7:53 AM, <akash77...@gmail.com> wrote:
Thanks.
This is what I was looking for.
Actually I am trying to learn graphs and was searching for a java api on it.Found yours and trying to learn more things.

One thing I wanted to raise against this design is , the Network interface ,
interface Network<N, E>

could be better if 
interface Network<N, E extends Comparable<E>>

If I am not wrong here, the edges must be comparable so that it can helpful while sorting for example in minimum spanning tree.

Also I have one more doubt regarding the api. Does this api implemented any algo of BFS or DFS or any applications of them.

Also can you please provide the timing when its (20.0) Beta phase will be completed and will be ready to use for any production application.

The @Beta annotation does not indicate that the feature/type is not suitable for production use. The common.graph package is used extensively inside of Google production services.

Read more about @Beta here.
 
To unsubscribe from this group and stop receiving emails from it, send an email to guava-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/guava-discuss/735c9dfe-463b-4d00-85c9-e8c32799deff%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
kak

Joshua O'Madadhain

unread,
Nov 22, 2016, 11:31:26 AM11/22/16
to Kurt Alfred Kluever, akash77...@gmail.com, guava-discuss, James Sexton, arvin...@hotmail.com, ankey...@gmail.com, sharma.sh...@gmail.com
On Mon, Nov 21, 2016 at 11:36 PM, 'Kurt Alfred Kluever' via guava-discuss <guava-...@googlegroups.com> wrote:

On Tue, Nov 22, 2016 at 7:53 AM, <akash77...@gmail.com> wrote:
Thanks.
This is what I was looking for.
Actually I am trying to learn graphs and was searching for a java api on it.Found yours and trying to learn more things.

One thing I wanted to raise against this design is , the Network interface ,
interface Network<N, E>

could be better if 
interface Network<N, E extends Comparable<E>>

If I am not wrong here, the edges must be comparable so that it can helpful while sorting for example in minimum spanning tree.

The edges need not be Comparable.  You can specify that the edges (or nodes) are sorted using the orderEdges() method on NetworkBuilder (or orderNodes() on any of the graph Builder classes); in that case either they need to be Comparable or you need to provide a Comparator.
 

Also I have one more doubt regarding the api. Does this api implemented any algo of BFS or DFS or any applications of them.

common.graph is primarily focused on providing a good API for graphs, and good implementations of that API.  It may provide implementations of BFS or DFS in future versions, but it is not expected to become a full-service graph library; it is likely to have a very limited selection of algorithms.  If you want a more full-featured graph library, you may want to check out either JUNG (which I am converting to use common.graph) or JGraphT.
 

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages