From: jxz12 Date: Thu, 9 Jan 2020 12:40:44 +0000 (+0000) Subject: first test X-Git-Tag: stable_release_2.44.0~12^2~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3860c6265eaecc1bdcdf22a443bb1616d1e001aa;p=graphviz first test --- diff --git a/lib/neatogen/neato.h b/lib/neatogen/neato.h index a7a59c3e5..0a9b528a5 100644 --- a/lib/neatogen/neato.h +++ b/lib/neatogen/neato.h @@ -26,6 +26,7 @@ #define MODE_MAJOR 1 #define MODE_HIER 2 #define MODE_IPSEP 3 +#define MODE_SGD 4 #define INIT_ERROR -1 #define INIT_SELF 0 diff --git a/lib/neatogen/neatoinit.c b/lib/neatogen/neatoinit.c index cd995e650..4da2a477f 100644 --- a/lib/neatogen/neatoinit.c +++ b/lib/neatogen/neatoinit.c @@ -670,6 +670,8 @@ static int neatoMode(graph_t * g) mode = MODE_IPSEP; #endif #endif + else if (streq(str, "sgd")) + mode = MODE_SGD; else agerr(AGWARN, "Illegal value %s for attribute \"mode\" in graph %s - ignored\n", @@ -1333,6 +1335,41 @@ static void kkNeato(Agraph_t * g, int nG, int model) } solve_model(g, nG); } +/* sgdNeato: + * Solve using stochastic gradient descent a la Zheng, Pawar, Goodman. + */ +static void sgdNeato(Agraph_t * g, int nG, int model) +{ + fprintf("hello, love from sgd"); + + if (model == MODEL_SUBSET) { + subset_model(g, nG); + } else if (model == MODEL_CIRCUIT) { + if (!circuit_model(g, nG)) { + agerr(AGWARN, + "graph %s is disconnected. Hence, the circuit model\n", + agnameof(g)); + agerr(AGPREV, + "is undefined. Reverting to the shortest path model.\n"); + agerr(AGPREV, + "Alternatively, consider running neato using -Gpack=true or decomposing\n"); + agerr(AGPREV, "the graph into connected components.\n"); + shortest_path(g, nG); + } + } else if (model == MODEL_MDS) { + shortest_path(g, nG); + mds_model(g, nG); + } else + shortest_path(g, nG); + initial_positions(g, nG); + diffeq_model(g, nG); + if (Verbose) { + fprintf(stderr, "Solving model %d iterations %d tol %f\n", + model, MaxIter, Epsilon); + start_timer(); + } + solve_model(g, nG); +} /* neatoLayout: * Use stress optimization to layout a single component @@ -1354,10 +1391,12 @@ neatoLayout(Agraph_t * mg, Agraph_t * g, int layoutMode, int layoutModel, nG = scan_graph_mode(g, layoutMode); if ((nG < 2) || (MaxIter < 0)) return; - if (layoutMode) - majorization(mg, g, nG, layoutMode, layoutModel, Ndim, MaxIter, am); - else + if (layoutMode == MODE_KK) kkNeato(g, nG, layoutModel); + else if (layoutMode == MODE_SGD) + sgdNeato(g, nG, layoutModel) + else + majorization(mg, g, nG, layoutMode, layoutModel, Ndim, MaxIter, am); } /* addZ;