kopia lustrzana https://github.com/jameshball/osci-render
Added skeleton code for adjacent node weightsa
rodzic
1af7df6a64
commit
41fc2a5380
|
@ -2,7 +2,7 @@
|
|||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/oscilloscope-experiments.iml" filepath="$PROJECT_DIR$/.idea/oscilloscope-experiments.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/oscilloscope-renderer.iml" filepath="$PROJECT_DIR$/.idea/oscilloscope-renderer.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,18 +8,21 @@ import java.util.List;
|
|||
public class Node {
|
||||
private Point location;
|
||||
private List<Node> adjacentNodes;
|
||||
private List<Double> 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() {
|
||||
|
|
Ładowanie…
Reference in New Issue