Skip to content

Commit d21dd1e

Browse files
author
somebody
committed
made Mathematica output from examples more robust against errors
1 parent 484461a commit d21dd1e

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

src/com/github/mjwach/steiner_tree_algorithms/examples/PlanarTreeExample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ public static void main(String[] arguments)
2222

2323
CalculatedSteinerTree graphs = DCELGraph.makeSteinerTreeAndDelaunayTriangulation(points, SteinerDuplicatePointPolicy.includeOnlyOneVertexPerLocation);
2424

25-
if (Printing.produceMathematicaCode) System.out.println("{");
25+
if (Printing.produceMathematicaCode) System.out.print("{");
2626

27-
Printing.performOn(graphs.steinerTree, "Steiner tree", "Red");
27+
Printing.performOn(graphs.steinerTree, "Steiner tree", "Magenta");
2828
if (!Printing.produceMathematicaCode) System.out.println();
2929

3030
if (Printing.produceMathematicaCode) System.out.println(", ");
3131

3232
Printing.performOn(graphs.delaunayTriangulation, "Delaunay triangulation", "Green");
3333

34-
if (Printing.produceMathematicaCode) System.out.println("}\n(* Paste the entire output of this program into Mathematica to see the graphs! *)");
34+
if (Printing.produceMathematicaCode) System.out.println("(* Paste the entire output of this program into Mathematica to see the graphs! Note that copying from the Eclipse console can add weird formatting - paste into a plain text editor first to strip that away! *)}");
3535
}
3636
}

src/com/github/mjwach/steiner_tree_algorithms/examples/Subgraph2DExample.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public static void main(String[] args)
5656

5757
graph.markSteinerSubgraph(terminals, steinerMarkIndex, NullInterruptionSignal.instance, options);
5858

59-
Printing.performOn(graph, steinerMarkIndex, steinerMarkIndex + 1, "Steiner tree", "Red");
60-
if (Printing.produceMathematicaCode) System.out.println("(* Paste the entire output of this program into Mathematica to see the graph! *)");
59+
if (Printing.produceMathematicaCode) System.out.print("{");
60+
Printing.performOn(graph, steinerMarkIndex, steinerMarkIndex + 1, "Steiner tree", "Magenta");
61+
if (Printing.produceMathematicaCode) System.out.println("(* Paste the entire output of this program into Mathematica to see the graph! Note that copying from the Eclipse console can add weird formatting - paste into a plain text editor first to strip that away! *)}");
6162
}
6263
}

src/com/github/mjwach/steiner_tree_algorithms/examples/Subgraph3DExample.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ public void addDiagonalEdge(int x, int y, int z, int random0123)
9292

9393
graph.markSteinerSubgraph(terminals, steinerMarkIndex, NullInterruptionSignal.instance, options);
9494

95-
Printing.performOn(graph, steinerMarkIndex, steinerMarkIndex + 1, "Steiner tree", "Red");
96-
if (Printing.produceMathematicaCode) System.out.println("(* Paste the entire output of this program into Mathematica to see the graph! *)");
95+
if (Printing.produceMathematicaCode) System.out.print("{");
96+
Printing.performOn(graph, steinerMarkIndex, steinerMarkIndex + 1, "Steiner tree", "Magenta");
97+
if (Printing.produceMathematicaCode) System.out.println("(* Paste the entire output of this program into Mathematica to see the graph! Note that copying from the Eclipse console can add weird formatting - paste into a plain text editor first to strip that away! *)}");
9798
}
9899
}

src/com/github/mjwach/steiner_tree_algorithms/examples/SubgraphArbitraryWeightsExample.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static void main(String[] args)
6666
{
6767
Printing.produceMathematicaCode = false; // change this to true if you want
6868

69-
if (Printing.produceMathematicaCode) System.out.println("{");
69+
if (Printing.produceMathematicaCode) System.out.print("{");
7070

7171
printGraph("Steiner tree (where the main graph is a grid with trivial edge weights)", new WeightFunction()
7272
{
@@ -116,8 +116,7 @@ public float actOn(PlaneVector v, int gridLength)
116116
}
117117
});
118118

119-
if (Printing.produceMathematicaCode) System.out.println("}");
120-
if (Printing.produceMathematicaCode) System.out.println("(* Paste the entire output of this program into Mathematica to see the graphs! *)");
119+
if (Printing.produceMathematicaCode) System.out.println("(* Paste the entire output of this program into Mathematica to see the graphs! Note that copying from the Eclipse console can add weird formatting - paste into a plain text editor first to strip that away! *)}");
121120
}
122121

123122
private static void printGraph(String graphName, WeightFunction weightFunction)
@@ -186,6 +185,6 @@ public int getIndex(int x, int y)
186185

187186
graph.markSteinerSubgraph(terminals, steinerMarkIndex, NullInterruptionSignal.instance, options);
188187

189-
Printing.performOn(graph, steinerMarkIndex, steinerMarkIndex + 1, graphName, "Red");
188+
Printing.performOn(graph, steinerMarkIndex, steinerMarkIndex + 1, graphName, "Magenta");
190189
}
191190
}

src/com/github/mjwach/steiner_tree_algorithms/examples/SubgraphManhattanDistanceExample.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ public static void main(String[] args)
4848
{
4949
Printing.produceMathematicaCode = false; // change this to true if you want
5050

51-
if (Printing.produceMathematicaCode) System.out.println("{");
51+
if (Printing.produceMathematicaCode) System.out.print("{");
5252

5353
printGraph("Graph", true, "Green", EdgeArraysGraph.defaultEdgeFactory);
5454
System.out.println(Printing.produceMathematicaCode ? "," : "");
55-
printGraph("Steiner tree of graph (Euclidean metric)", false, "Magenta", EdgeArraysGraph.defaultEdgeFactory);
55+
printGraph("Steiner tree of graph (Euclidean metric)", false, "Blue", EdgeArraysGraph.defaultEdgeFactory);
5656
System.out.println(Printing.produceMathematicaCode ? "," : "");
57-
printGraph("Steiner tree of graph (Manhattan metric)", false, "Red", new EdgeFactory()
57+
printGraph("Steiner tree of graph (Manhattan metric)", false, "Magenta", new EdgeFactory()
5858
{
5959
@Override
6060
public Edge act(Vertex end0, Vertex end1)
@@ -63,8 +63,7 @@ public Edge act(Vertex end0, Vertex end1)
6363
}
6464
});
6565

66-
if (Printing.produceMathematicaCode) System.out.println("}");
67-
if (Printing.produceMathematicaCode) System.out.println("(* Paste the entire output of this program into Mathematica to see the graphs! *)");
66+
if (Printing.produceMathematicaCode) System.out.println("(* Paste the entire output of this program into Mathematica to see the graphs! Note that copying from the Eclipse console can add weird formatting - paste into a plain text editor first to strip that away! *)}");
6867
}
6968

7069
private static void printGraph(String graphName, boolean drawGraphNotSteinerTree, String color, EdgeFactory edgeFactory)

0 commit comments

Comments
 (0)