Макет дерево в Гефи, похожая на графикJAVA

Программисты JAVA общаются здесь
Anonymous
Макет дерево в Гефи, похожая на график

Сообщение Anonymous »

С Gephi, как вы распорядите дерево, чтобы оно выглядело как изображение ниже?

Код: Выделить всё

java SimpleColorTree.java 4 100000 | dot -v -Ksfdp -Nshape=point '-Earrowsize=0.1' -Tpng -O


Консоль вывод (graphviz -v ):

Код: Выделить всё

dot - graphviz version 9.0.0 (20230911.1827)
libdir = "C:\Users\user\AppData\Local\Programs\Graphviz\bin"
Activated plugin library: gvplugin_neato_layout.dll
Using layout: sfdp:neato_layout
Using render: cairo:cairo
Using device: png:cairo:cairo
The plugin configuration file:
C:\Users\user\AppData\Local\Programs\Graphviz\bin\config6
was successfully loaded.
render      :  cairo dot dot_json fig gd gdiplus json json0 map mp pic pov ps svg tk vrml xdot xdot_json
layout      :  circo dot fdp neato nop nop1 nop2 osage patchwork sfdp twopi
textlayout  :  textlayout
device      :  bmp canon cmap cmapx cmapx_np dot dot_json emf emfplus eps fig gd gd2 gif gv imap imap_np ismap jpe jpeg jpg json json0 metafile mp pdf pic plain plain-ext png pov ps ps2 svg svgz tif tiff tk vrml wbmp xdot xdot1.2 xdot1.4 xdot_json
loadimage   :  (lib) bmp eps gd gd2 gif jpe jpeg jpg png ps svg
fontname: "Times-Roman" resolved to: (ps:pango  Times New Roman, ) (PangoCairoWin32Font) "Times New Roman, 13.9990234375"
overlap: none value 1953699328 scaling 0.0000
spring_electrical_control:
repulsive and attractive exponents: -1.000 1.000
random start 1 seed 123
K : -1.000 C : 0.200
max levels 2147483647
quadtree size 45 max_level 10
Barnes-Hutt constant 0.600 tolerance  0.001 maxiter 500
cooling 0.900 step size  0.100 adaptive 1
beautify_leaves 0 node weights 0 rotation 0.000
smoothing NONE overlap -1 initial_scaling -4.000 do_shrinking 1
octree scheme NORMAL
edge_labeling_scheme 0
ctrl->overlap=-1
Error: remove_overlap: Graphviz not built with triangulation library
Edge separation: add=1 (3.200000,3.200000)
Creating edges using line segments
Using render: cairo:cairo
Using device: png:cairo:cairo
dot: allocating a 11474K cairo image surface (1760 x 1669 pixels)
gvRenderJobs G: 3.47 secs.
Это то, что Gephi может сделать в 60 -х годах:

Это java class at emes em> em> emes em> eme sdepa rav Каждый узел, имеющий y дети:

Код: Выделить всё

// Usage: java SimpleColorTree   | dot -Tpng -o tree.png

public class SimpleColorTree  {
public static void main(String[] args) {
int children = Integer.parseInt(args[0]);
int totalNodes = Integer.parseInt(args[1]);
String[] colors = {"red", "blue", "green", "purple", "orange"};

System.out.println("digraph G {");
System.out.println("  0 [color=black];"); // Root is black

for (int node = 1; node < totalNodes; node++) {
int parent = (node - 1) / children;
int branchRoot = findBranchRoot(node, children);
String color = colors[branchRoot % colors.length];

System.out.printf("  %d -> %d [color=%s];\n", parent, node, color);
System.out.printf("  %d [color=%s];\n", node, color);
}

System.out.println("}");
}

// Finds the first-level child that is the root of this node's branch
private static int findBranchRoot(int node, int children) {
while (node > 1) {
int parent = (node - 1) / children;
if (parent == 0) return node; // Found first-level child
node = parent;
}
return 1; // Default if something goes wrong
}
}
< /code>
Это крошечное дерево с той же структурой: < /p>
java SimpleColorTree.java 4 100 | dot -v -Ksfdp -Nshape=point '-Earrowsize=0.1' -Tpng -O

По какой -то причине не может распространять эти ветви, когда график.>

Подробнее здесь: https://stackoverflow.com/questions/796 ... o-graphviz

Вернуться в «JAVA»