public Node whatNodeIGetTo(Node from, Transition with) { for (Edge e : myGraph.edgeSet()) { if (e.getSource().equals(from) && e.getTransition().equals(with)) { return e.getDest(); } } return null; }
private Graph buildGraph(List<Edge> edges) { Graph toReturn = new Graph(); for (Edge e : edges) { toReturn.addNode(e.getSource()); toReturn.addNode(e.getDest()); toReturn.addEdge(e); } return toReturn; }
public List<Graph> getAllNodeCoverage() { Node initial = getInitialState(); Set<Node> toVisit = new HashSet<>(nodes); toVisit.remove(initial); Set<Node> left = new HashSet<>(nodes); left.remove(initial); List<Graph> toReturn = new ArrayList<>(); for (Node visiting : toVisit) { if (left.contains(visiting)) { DijkstraShortestPath<Node, Edge> pathFinder = new DijkstraShortestPath<>(myGraph, initial, visiting); List<Edge> path = pathFinder.getPathEdgeList(); for (Edge e : path) { left.remove(e.getDest()); } toReturn.add(buildGraph(path)); } } return toReturn; }
public void addEdge(Edge toAdd) { myGraph.addEdge(toAdd.getSource(), toAdd.getDest(), toAdd); }