GraphBuilder.directed() and GraphBuilder.undirected() should not be parameterized on Object
See original GitHub issueI feel like I must be missing something, but I can’t figure out at all why these methods don’t look like:
public static <N> GraphBuilder<N> directed() { ... }
public static <N> GraphBuilder<N> undirected() { ... }
The current design means that it’s not possible to get a GraphBuilder
parameterized on anything besides Object
using these patterns until you call nodeOrder
, which will properly infer the generic type and perform a cast. (Incidentally, it feels strange that nodeOrder
has this generic downcasting behavior but, e.g., allowsSelfLoops
does not.)
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
GraphBuilder (Guava: Google Core Libraries for Java 20.0 API)
A builder for constructing instances of MutableGraph with user-defined properties. A graph built by this class will have the following properties by default:....
Read more >Graph (Guava: Google Core Libraries for Java 23.6-jre API)
Returns the count of node 's outgoing edges (equal to successors(node).size() ) in a directed graph. In an undirected graph, returns the degree(Object)...
Read more >GraphTypeBuilder (JGraphT : a free Java graph library)
A builder class for the hierarchy of Graph s that the library provides. The following example creates a directed graph which allows multiple...
Read more >com.google.common.truth.IterableSubject.hasSize java code ...
asList().hasSize(1); TypeVariable<?> captured = (TypeVariable<?>) typeArgs[0]; assertThat(captured.getBounds()).asList().containsExactly(Object.class); ...
Read more >guava/guava-tests/test/com/google/common/graph ... - Program Talk
you may not use this file except in compliance with the License. ... add parameters: directed/undirected ... return GraphBuilder.undirected().build();.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve got an update to the docs out for review now, so it should hopefully be in the next release of Guava.
Thanks for encouraging us to improve our documentation. 😃
Yup, the change covers them too, but thanks for asking. 😃
It also mentions that the types do get specified (i.e., don’t start out as
Object
) if you create a*Builder
using thefrom()
static method.