From 251dbbb074e992c2840d21c9506e215ceeadb98e Mon Sep 17 00:00:00 2001 From: Holt59 Date: Mon, 12 Mar 2018 21:12:31 +0100 Subject: [PATCH] Fix issue with ArcBackward being drawn. --- src/main/org/insa/graph/Node.java | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/org/insa/graph/Node.java b/src/main/org/insa/graph/Node.java index 8aadf84..966fdc8 100644 --- a/src/main/org/insa/graph/Node.java +++ b/src/main/org/insa/graph/Node.java @@ -33,10 +33,23 @@ public class Node implements Comparable { */ public static Arc linkNodes(Node origin, Node destination, float length, RoadInformation roadInformation, ArrayList points) { - ArcForward arc = new ArcForward(origin, destination, length, roadInformation, points); - origin.addSuccessor(arc); - if (!roadInformation.isOneWay()) { - destination.addSuccessor(new ArcBackward(arc)); + Arc arc = null; + if (roadInformation.isOneWay()) { + arc = new ArcForward(origin, destination, length, roadInformation, points); + origin.addSuccessor(arc); + } + else { + Arc d2o; + if (origin.getId() < destination.getId()) { + arc = new ArcForward(origin, destination, length, roadInformation, points); + d2o = new ArcBackward(arc); + } + else { + d2o = new ArcForward(destination, origin, length, roadInformation, points); + arc = new ArcBackward(d2o); + } + origin.addSuccessor(arc); + destination.addSuccessor(d2o); } return arc; }