Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit977b625

Browse files
committed
Allow method chaining only for property setters
1 parentab8e921 commit977b625

File tree

2 files changed

+55
-24
lines changed

2 files changed

+55
-24
lines changed

‎src/main/java/org/algorithm_visualizer/GraphTracer.java

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,31 @@ public GraphTracer weighted() {
2525
returnthis;
2626
}
2727

28+
publicGraphTracerlayoutCircle() {
29+
command("layoutCircle",newObject[]{});
30+
returnthis;
31+
}
32+
33+
publicGraphTracerlayoutTree(Objectroot,booleansorted) {
34+
command("layoutTree",newObject[]{root,sorted});
35+
returnthis;
36+
}
37+
38+
publicGraphTracerlayoutTree(Objectroot) {
39+
command("layoutTree",newObject[]{root});
40+
returnthis;
41+
}
42+
43+
publicGraphTracerlayoutTree() {
44+
command("layoutTree",newObject[]{});
45+
returnthis;
46+
}
47+
48+
publicGraphTracerlayoutRandom() {
49+
command("layoutRandom",newObject[]{});
50+
returnthis;
51+
}
52+
2853
publicvoidaddNode(Objectid,doubleweight,doublex,doubley,intvisitedCount,intselectedCount) {
2954
command("addNode",newObject[]{id,weight,x,y,visitedCount,selectedCount});
3055
}
@@ -113,26 +138,6 @@ public void removeEdge(Object source, Object target) {
113138
command("removeEdge",newObject[]{source,target});
114139
}
115140

116-
publicvoidlayoutCircle() {
117-
command("layoutCircle",newObject[]{});
118-
}
119-
120-
publicvoidlayoutTree(Objectroot,booleansorted) {
121-
command("layoutTree",newObject[]{root,sorted});
122-
}
123-
124-
publicvoidlayoutTree(Objectroot) {
125-
command("layoutTree",newObject[]{root});
126-
}
127-
128-
publicvoidlayoutTree() {
129-
command("layoutTree",newObject[]{});
130-
}
131-
132-
publicvoidlayoutRandom() {
133-
command("layoutRandom",newObject[]{});
134-
}
135-
136141
publicvoidvisit(Objecttarget,Objectsource,doubleweight) {
137142
command("visit",newObject[]{target,source,weight});
138143
}
Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
11
packageorg.algorithm_visualizer;
22

3+
importorg.algorithm_visualizer.*;
4+
35
classTest {
6+
staticGraphTracertracer =newGraphTracer();
7+
tracer.log(newLogTracer());
8+
staticintG[][] = {// G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
9+
{0,1,1,0,0,0,0,0,0,0,0},
10+
{0,0,0,1,1,0,0,0,0,0,0},
11+
{0,0,0,0,0,1,1,0,0,0,0},
12+
{0,0,0,0,0,0,0,1,1,0,0},
13+
{0,0,0,0,0,0,0,0,0,1,1},
14+
{0,0,0,0,0,0,0,0,0,0,0},
15+
{0,0,0,0,0,0,0,0,0,0,0},
16+
{0,0,0,0,0,0,0,0,0,0,0},
17+
{0,0,0,0,0,0,0,0,0,0,0},
18+
{0,0,0,0,0,0,0,0,0,0,0},
19+
{0,0,0,0,0,0,0,0,0,0,0},
20+
};
21+
22+
staticvoidDFS(intnode,intparent) {// node = current node, parent = previous node
23+
tracer.visit(node,parent).delay();
24+
for (inti =0;i <G[node].length;i++) {
25+
if (G[node][i] ==1) {// if current node has the i-th node as a child
26+
DFS(i,node);// recursively call DFS
27+
}
28+
}
29+
}
30+
431
publicstaticvoidmain(String[]args) {
5-
ChartTracerchartTracer =newChartTracer();
6-
chartTracer.set(newObject[]{});
7-
Layout.setRoot(newVerticalLayout(newCommander[]{chartTracer}));
32+
tracer.set(G).layoutTree(0).delay();
33+
DFS(0, -1);
834
}
9-
}
35+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp