diff --git a/.idea/modules.xml b/.idea/modules.xml index a17948dd..f16059fc 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/oscilloscope-experiments.iml b/.idea/oscilloscope-renderer.iml similarity index 100% rename from .idea/oscilloscope-experiments.iml rename to .idea/oscilloscope-renderer.iml diff --git a/src/graphs/Graph.java b/src/graphs/Graph.java index c084756d..93eb8cba 100644 --- a/src/graphs/Graph.java +++ b/src/graphs/Graph.java @@ -26,8 +26,8 @@ public class Graph { Node nodeA = nodes.get(line.getA()); Node nodeB = nodes.get(line.getB()); - nodeA.addAdjacent(nodeB); - nodeB.addAdjacent(nodeA); + nodeA.addAdjacent(nodeB, line.length); + nodeB.addAdjacent(nodeA, line.length); } } } diff --git a/src/graphs/Node.java b/src/graphs/Node.java index 775e9f7d..b688cf5e 100644 --- a/src/graphs/Node.java +++ b/src/graphs/Node.java @@ -8,18 +8,21 @@ import java.util.List; public class Node { private Point location; private List adjacentNodes; + private List adjacentWeights; public Node(Point location) { this.location = location; this.adjacentNodes = new ArrayList<>(); + this.adjacentWeights = new ArrayList<>(); } public Point getLocation() { return location; } - public void addAdjacent(Node node) { + public void addAdjacent(Node node, double weight) { adjacentNodes.add(node); + adjacentWeights.add(weight); } public int degree() {