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">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<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>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -26,8 +26,8 @@ public class Graph {
|
||||||
Node nodeA = nodes.get(line.getA());
|
Node nodeA = nodes.get(line.getA());
|
||||||
Node nodeB = nodes.get(line.getB());
|
Node nodeB = nodes.get(line.getB());
|
||||||
|
|
||||||
nodeA.addAdjacent(nodeB);
|
nodeA.addAdjacent(nodeB, line.length);
|
||||||
nodeB.addAdjacent(nodeA);
|
nodeB.addAdjacent(nodeA, line.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,18 +8,21 @@ import java.util.List;
|
||||||
public class Node {
|
public class Node {
|
||||||
private Point location;
|
private Point location;
|
||||||
private List<Node> adjacentNodes;
|
private List<Node> adjacentNodes;
|
||||||
|
private List<Double> adjacentWeights;
|
||||||
|
|
||||||
public Node(Point location) {
|
public Node(Point location) {
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.adjacentNodes = new ArrayList<>();
|
this.adjacentNodes = new ArrayList<>();
|
||||||
|
this.adjacentWeights = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getLocation() {
|
public Point getLocation() {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAdjacent(Node node) {
|
public void addAdjacent(Node node, double weight) {
|
||||||
adjacentNodes.add(node);
|
adjacentNodes.add(node);
|
||||||
|
adjacentWeights.add(weight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int degree() {
|
public int degree() {
|
||||||
|
|
Ładowanie…
Reference in New Issue