Skip to content

MutableNetwork.hasEdgeConnecting throw IllegalArgumentException when node are missing #3721

@fathzer

Description

@fathzer

According to the javadoc, the hasEdgeConnecting method is equivalent to nodes().contains(nodeU) && successors(nodeU).contains(nodeV).
But, unlike this expression, it throws an exception if the nodes are unknown.
Here is a simple demonstration

import com.google.common.graph.MutableNetwork;
import com.google.common.graph.NetworkBuilder;

public class Bug {
	public static void main(String[] args) {
		final MutableNetwork<String, String> graph = NetworkBuilder.undirected().allowsParallelEdges(false).build();
		// Foolowing line prints false
		System.out.println(graph.nodes().contains("1") && graph.successors("1").contains("2"));
		// Next should print false but throws an IllegalArgumentException
		System.out.println(graph.hasEdgeConnecting("1", "2"));
	}
}

version guava-28.1-jre

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions