... | ... |
@@ -678,48 +678,49 @@ |
678 | 678 |
|
679 | 679 |
// bool eps; |
680 | 680 |
bool disc_d, square_d, gauss_d; |
681 | 681 |
// bool tsp_a,two_a,tree_a; |
682 | 682 |
int num_of_cities=1; |
683 | 683 |
double area=1; |
684 | 684 |
N=100; |
685 | 685 |
// girth=10; |
686 | 686 |
std::string ndist("disc"); |
687 | 687 |
ap.refOption("n", "Number of nodes (default is 100)", N) |
688 | 688 |
.intOption("g", "Girth parameter (default is 10)", 10) |
689 | 689 |
.refOption("cities", "Number of cities (default is 1)", num_of_cities) |
690 | 690 |
.refOption("area", "Full relative area of the cities (default is 1)", area) |
691 | 691 |
.refOption("disc", "Nodes are evenly distributed on a unit disc (default)",disc_d) |
692 | 692 |
.optionGroup("dist", "disc") |
693 | 693 |
.refOption("square", "Nodes are evenly distributed on a unit square", square_d) |
694 | 694 |
.optionGroup("dist", "square") |
695 | 695 |
.refOption("gauss", |
696 | 696 |
"Nodes are located according to a two-dim gauss distribution", |
697 | 697 |
gauss_d) |
698 | 698 |
.optionGroup("dist", "gauss") |
699 | 699 |
// .mandatoryGroup("dist") |
700 | 700 |
.onlyOneGroup("dist") |
701 | 701 |
.boolOption("eps", "Also generate .eps output (prefix.eps)") |
702 |
.boolOption("nonodes", "Draw the edges only in the generated .eps") |
|
702 | 703 |
.boolOption("dir", "Directed digraph is generated (each arcs are replaced by two directed ones)") |
703 | 704 |
.boolOption("2con", "Create a two connected planar digraph") |
704 | 705 |
.optionGroup("alg","2con") |
705 | 706 |
.boolOption("tree", "Create a min. cost spanning tree") |
706 | 707 |
.optionGroup("alg","tree") |
707 | 708 |
.boolOption("tsp", "Create a TSP tour") |
708 | 709 |
.optionGroup("alg","tsp") |
709 | 710 |
.boolOption("tsp2", "Create a TSP tour (tree based)") |
710 | 711 |
.optionGroup("alg","tsp2") |
711 | 712 |
.boolOption("dela", "Delaunay triangulation digraph") |
712 | 713 |
.optionGroup("alg","dela") |
713 | 714 |
.onlyOneGroup("alg") |
714 | 715 |
.boolOption("rand", "Use time seed for random number generator") |
715 | 716 |
.optionGroup("rand", "rand") |
716 | 717 |
.intOption("seed", "Random seed", -1) |
717 | 718 |
.optionGroup("rand", "seed") |
718 | 719 |
.onlyOneGroup("rand") |
719 | 720 |
.other("[prefix]","Prefix of the output files. Default is 'lgf-gen-out'") |
720 | 721 |
.run(); |
721 | 722 |
|
722 | 723 |
if (ap["rand"]) { |
723 | 724 |
int seed = time(0); |
724 | 725 |
std::cout << "Random number seed: " << seed << std::endl; |
725 | 726 |
rnd = Random(seed); |
... | ... |
@@ -798,37 +799,37 @@ |
798 | 799 |
std::cout << "Make triangles\n"; |
799 | 800 |
// triangle(); |
800 | 801 |
sparseTriangle(ap["g"]); |
801 | 802 |
std::cout << "Make it sparser\n"; |
802 | 803 |
sparse2(ap["g"]); |
803 | 804 |
} |
804 | 805 |
else if(ap["tree"]) { |
805 | 806 |
minTree(); |
806 | 807 |
} |
807 | 808 |
else if(ap["dela"]) { |
808 | 809 |
delaunay(); |
809 | 810 |
} |
810 | 811 |
|
811 | 812 |
|
812 | 813 |
std::cout << "Number of nodes : " << countNodes(g) << std::endl; |
813 | 814 |
std::cout << "Number of arcs : " << countEdges(g) << std::endl; |
814 | 815 |
double tlen=0; |
815 | 816 |
for(EdgeIt e(g);e!=INVALID;++e) |
816 | 817 |
tlen+=sqrt((coords[g.v(e)]-coords[g.u(e)]).normSquare()); |
817 | 818 |
std::cout << "Total arc length : " << tlen << std::endl; |
818 | 819 |
|
819 | 820 |
if(ap["eps"]) |
820 | 821 |
graphToEps(g,prefix+".eps").scaleToA4(). |
821 | 822 |
scale(600).nodeScale(.005).arcWidthScale(.001).preScale(false). |
822 |
coords(coords).run(); |
|
823 |
coords(coords).hideNodes(ap.given("nonodes")).run(); |
|
823 | 824 |
|
824 | 825 |
if(ap["dir"]) |
825 | 826 |
DigraphWriter<ListGraph>(g,prefix+".lgf"). |
826 | 827 |
nodeMap("coordinates_x",scaleMap(xMap(coords),600)). |
827 | 828 |
nodeMap("coordinates_y",scaleMap(yMap(coords),600)). |
828 | 829 |
run(); |
829 | 830 |
else GraphWriter<ListGraph>(g,prefix+".lgf"). |
830 | 831 |
nodeMap("coordinates_x",scaleMap(xMap(coords),600)). |
831 | 832 |
nodeMap("coordinates_y",scaleMap(yMap(coords),600)). |
832 | 833 |
run(); |
833 | 834 |
} |
834 | 835 |
|
0 comments (0 inline)