Skip to content

Instantly share code, notes, and snippets.

@davidjgraph
Created November 4, 2015 14:06
Show Gist options
  • Save davidjgraph/480cdaa28c676572b63a to your computer and use it in GitHub Desktop.
Save davidjgraph/480cdaa28c676572b63a to your computer and use it in GitHub Desktop.
organic layout parameters
<!--
Copyright (c) 2006-2013, JGraph Ltd
Hierarchical Layout example for mxGraph. This example demonstrates the
use of the hierarchical and organic layouts. Note that the hierarchical
layout requires another script tag in the head of the page.
-->
<html>
<head>
<title>Hierarchical Layout example for mxGraph</title>
<!-- Sets the basepath for the library if not in same directory -->
<script type="text/javascript">
mxBasePath = '../src';
</script>
<!-- Loads and initializes the library -->
<script type="text/javascript" src="../src/js/mxClient.js"></script>
<!-- Example code -->
<script type="text/javascript">
// Program starts here. Creates a sample graph in the
// DOM node with the specified ID. This function is invoked
// from the onLoad event handler of the document (see below).
function main(container)
{
// Checks if browser is supported
if (!mxClient.isBrowserSupported())
{
// Displays an error message if the browser is
// not supported.
mxUtils.error('Browser is not supported!', 200, false);
}
else
{
var graph = new mxGraph(container);
var style = graph.getStylesheet().getDefaultVertexStyle();
style[mxConstants.STYLE_PERIMETER] = mxPerimeter.RectanglePerimeter;
style = graph.getStylesheet().getDefaultEdgeStyle();
var organic = new mxFastOrganicLayout(graph);
var parent = graph.getDefaultParent();
// You can increase this constant and will see issue
var size = 200;
graph.getModel().beginUpdate();
var nodesString = "1146,1147,1148,1149,1150,1151,1152,1153,1154,1155,1156,1157,1158,1159,1160,1161,1162,1163,1164,1165,1166,1167,1168,1169,1170,1171,1172,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,1303,1304,1305,1306,1307,1308,1309,1310,1311,1312,1313,1314,1315,1316,1317,1318,1319,1320,1321,1322,1323,1324,1325,1326,1327,1328,1329,1330,1331,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,1342,1343,1344,1345,1346,1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,1360,1361,1362,1363,1364,1365,1366,1367,1368,1369,1370,1371,1372,1373,1374,1375,1376,1377,1378,1379,1380,1381,1382,1383,1384,1385,1386,1387,1388,1389,1390,1391,1392,1393,1394,1395,1396,1397,1398,1399,1400,1401,1402,1403,1404,1405,1406,1407,1408,1409,1410,1411,1412,1413,1414,1415,1416,1417,1418,1419,1420,1421,1422,1423,1424,1425,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477,1478,1479,1480,1481,1482,1483,1484,1485,1486,1487,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,1515,1516,1517,1518,1519,1520,1521,1522,1523,1524,1525,1526,1527,1528,1529,1530,1531,1532,1533,1534,1535,1536,1537,1538,1539,1540,1541,1542,1543,1544,1545,1546,1547,1548,1549,1550,1551,1552,1553,1554,1555,1556,1557,1558,1559,1560,1561,1562,1563,1564,1565,1566,1567,1568,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,1595,1596,1597,1598,1599,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1611,1612,1613,1614,1615,1616,1617,1618,1619,1620,1621,1622,1623,1624,1625,1626,1627,1628,1629,1630,1631,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,1642,1643,1644,1645,1646,1647,1648,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1668,1669,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718,1719,1720,1721,1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,1734,1735,1736,1737,1738,1739,1740,1741,1742,1743,1744,1745,1746,1747,1748,1749,1750,1751,1752,1753,1754,1755,1756,1757,1758,1759,1760,1761,1762,1764,1765,1766,1767,1768,1769,1770,1771,1772,1773,1774,1775,1776,1777,1778,1779,1780,1781,1782,1783,1784,1785,1786,1787,1788,1789,1790,1791,1792,1793,1794,1795,1796,1797,1798,1799,1800,1801,1802,1803,1804,1805,1806,1807,1808,1809,1810,1811,1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1823,1824,1825,1826,1827,1828,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,1840,1841,1842,1843,1844,1845,1846,1847,1848,1849,1850,1851,1852,1853,1854,1855,1856,1857,1858,1860,1861,1862,1863,1864,1865,1866,1867,1868,1869,1870,1871,1872,1873,1874,1875,1876,1877,1878,1879,1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030";
var edgesString = "1182;1157,1163;1187,1169;1189,1208;1164,1210;1208,1163;1211,1222;1171,1222;1209,1225;1200,1170;1236,1159;1243,1249;1163,1255;1222,1236;1257,1260;1238,1260;1257,1245;1260,1260;1271,1225;1275,1182;1280,1292;1189,1182;1305,1306;1189,1308;1236,1308;1260,1314;1172,1189;1317,1260;1320,1172;1321,1333;1215,1333;1174,1333;1197,1213;1333,1272;1333,1281;1333,1208;1334,1337;1222,1343;1208,1182;1346,1348;1163,1352;1151,1352;1216,1201;1352,1340;1352,1358;1357,1358;1218,1358;1155,1175;1358,1225;1363,1367;1260,1368;1262,1236;1370,1222;1375,1381;1222,1163;1387,1333;1388,1146;1390,1270;1390,1394;1333,1208;1396,1208;1397,1398;1352,1402;1352,1208;1403,1236;1407,1409;1390,1412;1260,1414;1390,1172;1418,1236;1421,1208;1425,1390;1428,1236;1430,1358;1432,1437;1260,1438;1390,1439;1260,1440;1222,1459;1189,1390;1471,1358;1472,1474;1377,1474;1436,1474;1162,1193;1474,1189;1476,1260;1477,1478;1236,1479;1389,1479;1400,1479;1362,1444;1479,1485;1222,1356;1487,1435;1487,1479;1497,1503;1208,1358;1507,1509;1182,1352;1509,1511;1467,1352;1512,1262;1513,1222;1516,1182;1522,1526;1253,1300;1526,1321;1526,1466;1526,1182;1530,1531;1172,1182;1532,1182;1539,1543;1163,1333;1547,1390;1548,1550;1208,1474;1551,1553;1208,1181;1554,1226;1554,1400;1554,1474;1556,1358;1560,1563;1182,1564;1400,1252;1564,1523;1564,1564;1566,1567;1208,1569;1172,1526;1569,1575;1564,1578;1173,1582;1581,1582;1342,1582;1359,1582;1379,1582;1178,1582;1307,1325;1582,1328;1582,1417;1582,1433;1582,1457;1582,1586;1172,1588;1352,1469;1589,1564;1590,1390;1591,1592;1189,1596;1260,1163;1597,1599;1182,1208;1604,1608;1313,1608;1595,1453;1608,1475;1608,1572;1608,1225;1609,1611;1526,1208;1615,1616;1358,1616;1608,1616;1208,1390;1616,1236;1620,1487;1625,1627;1262,1479;1631,1395;1634,1582;1637,1492;1638,1262;1639,1642;1269,1642;1452,1642;1569,1642;1321,1642;1427,1148;1642,1541;1642,1643;1638,1643;1640,1366;1643,1236;1648,1650;1192,1650;1351,1650;1382,1650;1278,1650;1504,1177;1650,1257;1650,1276;1650,1308;1650,1361;1650,1365;1650,1424;1650,1468;1650,1608;1651,1653;1251,1655;1649,1655;1509,1655;1199,1327;1655,1558;1655,1656;1655,1225;1657,1659;1222,1608;1660,1662;1163,1665;1474,1260;1666,1667;1246,1668;1487,1333;1669,1671;1182,1672;1236,1333;1674,1352;1676,1352;1677,1148;1678,1269;1678,1321;1678,1427;1678,1452;1678,1541;1678,1569;1678,1352;1680,1683;1390,1684;1221,1684;1310,1684;1401,1684;1505,1684;1546,1684;1661,1684;1633,1374;1684,1626;1684,1632;1684,1685;1487,1514;1687,1222;1689,1690;1650,1694;1312,1694;1565,1694;1179,1694;1462,1257;1694,1308;1694,1482;1694,1695;1262,1696;1678,1642;1696,1697;1629,1697;1652,1697;1456,1697;1212,1354;1697,1517;1697,1616;1697,1225;1698,1699;1352,1701;1681,1701;1502,1701;1593,1701;1431,1701;1332,1701;1450,1701;1509,1701;1268,1203;1701,1483;1701,1691;1701,1703;1208,1706;1684,1709;1244,1709;1400,1279;1709,1717;1644,1720;1684,1222;1722,1725;1697,1730;1390,1732;1186,1732;1258,1732;1610,1732;1636,1147;1732,1248;1732,1322;1732,1584;1732,1208;1734,1736;1416,1736;1635,1736;1654,1736;1347,1736;1622,1736;1188,1231;1736,1311;1736,1393;1736,1737;1684,1163;1737,1189;1737,1222;1737,1333;1737,1738;1684,1739;1283,1739;1287,1739;1291,1739;1630,1739;1324,1739;1733,1739;1443,1399;1739,1509;1739,1559;1739,1728;1739,1739;1740,1743;1182,1182;1746,1747;1172,1423;1749,1608;1750,1751;1642,1751;1678,1554;1754,1352;1756,1236;1760,1222;1761,1766;1262,1767;1415,1767;1686,1767;1316,1767;1180,1767;1289,1183;1767,1195;1767,1267;1767,1442;1767,1509;1767,1767;1769,1487;1771,1236;1772,1774;1739,1776;1352,1778;1222,1783;1679,1783;1369,1783;1700,1783;1284,1783;1220,1783;1602,1783;1261,1330;1783,1454;1783,1498;1783,1500;1783,1552;1783,1616;1783,1709;1784,1786;1608,1352;1787,1788;1582,1790;1678,1642;1790,1792;1647,1792;1400,1792;1561,1792;1473,1355;1792,1793;1207,1793;1726,1793;1229,1411;1793,1544;1793,1794;1579,1794;1455,1794;1353,1794;1515,1794;1449,1794;1540,1794;1373,1309;1794,1451;1794,1759;1794,1795;1694,1796;1172,1225;1797,1701;1799,1800;1542,1801;1236,1701;1802,1804;1189,1225;1805,1808;1739,1810;1208,1554;1812,1813;1352,1182;1814,1815;1352,1236;1816,1817;1697,1358;1818,1822;1794,1826;1487,1333;1827,1358;1828,1829;1390,1833;1163,1793;1835,1837;1608,1608;1838,1697;1839,1793;1840,1841;1694,1843;1352,1582;1844,1352;1847,1849;1333,1163;1849,1189;1849,1222;1849,1684;1849,1851;1767,1852;1694,1496;1853,1222;1854,1856;1582,1487;1860,1861;1208,1862;1732,1863;1390,1867;1694,1868;1172,1582;1870,1871;1182,1872;1333,1262;1874,1208;1875,1222;1879,1225;1886,1887;1366,1887;1640,1492;1887,1646;1888,1608;1890,1891;1262,1222;1892,1893;1208,1655;1894,1697;1897,1900;1678,1642;1900,1333;1901,1903;1239,1903;1446,1903;1419,1903;1538,1903;1594,1903;1873,1903;1764,1903;1153,1903;1831,1223;1903,1282;1903,1426;1903,1464;1903,1549;1903,1606;1903,1616;1903,1617;1903,1711;1903,1781;1903,1260;1907,1260;1908,1910;1262,1910;1732,1910;1474,1487;1910,1582;1910,1736;1910,1793;1910,1794;1910,1911;1526,1913;1172,1352;1914,1208;1916,1474;1917,1655;1919,1920;1390,1182;1922,1650;1925,1926;1554,1767;1927,1222;1929,1903;1931,1352;1932,1783;1933,1352;1934,1935;1525,1935;1285,1935;1257,1935;1385,1308;1935,1335;1935,1360;1935,1845;1935,1582;1937,1938;1487,1941;1607,1942;1608,1943;1709,1479;1943,1554;1943,1564;1943,1792;1943,1944;1479,1225;1946,1948;1678,1642;1948,1684;1949,1222;1951,1333;1953,1479;1954,1956;1678,1956;1642,1526;1957,1959;1236,1163;1961,1526;1962,1963;1684,1965;1655,1965;1767,1965;1352,1965;1701,1182;1965,1739;1965,1966;1684,1358;1967,1968;1642,1968;1678,1794;1969,1970;1724,1970;1576,1970;1404,1970;1465,1970;1256,1970;1372,1970;1494,1970;1499,1970;1855,1970;1509,1219;1970,1274;1970,1376;1970,1486;1970,1489;1970,1529;1970,1753;1970,1965;1970,1971;1767,1973;1172,1794;1974,1697;1976,1977;1163,1582;1978,1981;1736,1981;1732,1981;1487,1981;1793,1981;1262,1225;1981,1474;1981,1582;1981,1794;1981,1982;1621,1983;1935,1984;1955,1984;1410,1984;1821,1984;1257,1247;1984,1308;1984,1577;1984,1782;1984,1985;1684,1697;1988,1794;1989,1990;1172,1732;1991,1992;1390,1390;1993,1225;1995,1694;1996,1222;1997,1260;1998,1783;1999,2002;1791,2003;1903,1182;2004,2007;1783,2007;1697,2007;1903,2007;1358,1208;2007,1390;2007,1608;2007,1189;2008,2010;1352,2011;1526,1736;2015,1554;2017,1189;2018,1582;2019,1225;2020,2021;1739,1392;2022,1352;2025,1783;2026,1697;2028,1970;2029,1333;2030,1616;1941,1882;1687,1395;1542,1481;1982,1600;1331,1986;1578,1557;1621,1447;1752,1881;1492,1643;2016,1644;1165,1349;1242,1434;1573,1765;1484,1573;2012,1542;1254,1557;1339,1506;1846,1607;2007,1492;1643,1982;1947,1573;1692,1448;1864,1803;1634,1915;1296,1492;1521,1573;1447,1154;1573,1777;1779,1235;1982,1717;1921,1842;1277,1290;1542,1634;1864,1646;1910,2024;1921,1492;1573,1798;1930,1881;1638,1527;1524,1869;1865,1384;1687,1982;1735,1400;1496,1638;1965,1646;1234,2023;1447,1634;1400,1981;2002,1664;1687,1748;1277,1915;1508,1589;1319,1634;1534,1323;1533,1960;1712,1495;1447,1323;1621,1395;1534,1918;1540,1447;2005,1447;1950,1326;1251,1616;1607,1598;1712,1719;1589,1173;1866,1707;1923,1882;1514,1638;1521,1735;1621,1638;1809,1857;1469,1960;2009,1687;1535,1612;1514,1492;1600,2013;1638,1896;1540,1670;1573,1982;1902,1400;1853,1380;1447,1293;1578,1638;1972,1982;1877,1824;1842,1621;1492,1383;1514,1573;1884,1673;1196,1257;1392,1573;1628,1864;1568,1447;1246,1741;1492,1391;1945,1848;1721,1447;1692,1752;1585,1634;1308,1915;1413,1638;1621,1395;1463,1166;1644,1574;1447,1798;1634,1848;1573,1400;1943,1644;1643,1323;1982,1718;1542,1641;1514,1621;1481,1864;1930,1621;1902,1273;1887,1263;1371,1960;1663,1757;1687,1224;1540,1194;1982,1975;1687,1878;1514,1493;1643,1889;1646,1488;1638,1708;1621,1981;1910,1165;1717,1458;1540,1204;1470,1603;1161,1675;1277,1713;2023,1943;1496,1235;1823,1762;1589,1621;1194,1887;1638,1422;1573,1321;1569,1589;1682,1687;1785,1492;1737,1960;1716,1717;1904,1789;1187,1589;1232,1528;1445,1491;1341,1400;1395,1447;1702,1634;1800,1773;1800,1864;1406,1159;1965,1972;1288,1905;1406,1298;1187,1568;1928,1492;1832,1982;1899,1960;1508,1542;1491,1295;1898,1964;1888,1573;1952,1688;1982,1250;1646,1528;1864,1707;1589,1542;1338,1798;1568,1492;2013,1960;1717,1447;1492,1947;1149,1644;1981,1573;1994,1165;1904,1798;1928,1899;1621,1752;1573,1542;1693,1600;1315,1902;1939,1800;1807,1981;1578,1887;1493,1888;1981,1811;1520,1936;1678,1190;1514,1434;2012,1429;1864,1775;1187,1762;1958,1510;1173,1266;1589,1555;1227,1603;1395,1910;1717,2022;1308,2006;1623,1542;1807,1809;1492,1395;1257,1718;1715,1830;1469,1484;1621,1573;1713,1621;1877,1915;1712,1469;1191,1638;1880,1836;1266,1344;1562,1448;1160,1509;1965,1235;1480,1469;1707,1524;1621,2001;1542,1349;1982,1800;1338,1737;1423,1154;1714,1982;1492,1571;1526,1420;1687,1251;1982,1603;1842,1621;1876,1259;1888,1710;1302,1573;1204,1173;1981,1912;1800,1749;1849,1166;1345,1960;1158,1345;1644,1888;1250,1605;1211,1467;1321,1638;1849,1447;1204,1573;1470,1915;1227,1644;1910,1509;1159,1447;1422,1834;1290,1237;1682,1395;1864,1211;1240,1791;1981,1445;1798,1573;1950,1850;2014,1737;1749,1333;1184,1849;1492,1846;1469,1864;1905,1864;1445,1573;1585,1658;1887,1965;1492,1514;1664,1824;1603,1573;1185,1729;1233,1952;1185,1832;2013,1277;1634,1616;1638,1405;1638,1972;1741,1682;1518,1510;1578,1447;1585,1166;1717,1624;1492,1214;1315,1297;1915,1589;1191,1574;1573,1514;1176,1982;1800,1395;1803,1713;1447,1798;1429,1638;1777,1469;1719,1264;1187,1714;1573,1800;1254,1537;1688,1800;1718,1644;1469,1198;1187,1643;1811,1644;1921,1228;1663,1723;1191,1848;1447,1687;1878,1555;1960,1825;1621,1915;1304,2027;1646,1447;1714,1646;1583,1887;1643,1621;1391,1687;1383,1573;1727,1888;1234,1405;1492,1981;1514,1555;1915,1675;1161,1702;1758,1982;1490,1488;1303,1819;1241,1982;1745,1924;1638,1710;1800,1519;1277,1737;2014,1618;1251,1214;1600,1888;1230,1876;1883,1420;1514,1811;1887,1798;1395,1880;1405,1687;1176,1924;1492,1492;1315,1825;1895,1589;1940,1167;1980,1770;1542,1349;1621,1158;1705,1621;1980,1413;2009,1889;1888,1877;1168,1887;1717,1825;1982,1321;1318,1447;1470,1542;1623,1288;1741,1321;1241,1573;1545,1187;1536,1241;1569,1885;1469,1448;1798,1557;1982,1702;1573,1943;1853,1520;1643,1888;1583,1230;1646,2024;1644,1777;1492,1909;1296,1646;1336,1768;1770,1682;1469,1708;1614,1638;2007,1644;1915,1603;1675,1257;1308,1308;1392,1616;2007,1638;1315,1915;1909,1876;1150,1173;1910,1540;2000,1905;1798,1687;1190,1509;1492,1321;1819,1887;2016,1202;1940,1589;1729,1490;1621,1514;1757,1492;1488,1580;1391,1542;1217,1687;1981,1447;1884,1447;1628,1658;1643,1266;1469,1621;1688,1832;1638,1624;1638,1987;1441,1869;1542,1727;1704,1819;1569,1980;1982,1492;1972,1514;1384,1336;1888,1467;1569,1277;1395,1294;1338,2027;1888,1899;1806,1514;1785,1447;1994,1621;1251,1846;1589,1492;1616,1910;1578,1800;1770,1299;1643,1469;1232,2001;1800,1721;1447,1888;1910,1960;1909,1447;2012,1492;1303,1982;1469,1641;1687,1898;1621,1688;1744,1915;1716,1573;2023,1469;1940,1265;1578,1257;2022,1915;2009,1982;1876,1758;1573,1888;1501,1447;1185,1623;1800,1524;1982,1881;1521,1509;1638,1670;1950,1380;1573,1469;1319,1628;1545,1447;1434,1994;1884,1492;1460,1915;1158,1612;1687,1514;1535,2014;1673,1469;1729,1887;1803,1277;1603,1225;1263,1885;1589,1286;1972,1329;1982,1598;1915,1638;1573,1707;1619,1569;1511,1849;1196,1514;1910,1800;1217,1172;1780,1225;1371,1858;1578,1514;1975,1447;1441,1350;1490,1645;1173,1154;1447,1645;1578,1638;1601,1682;1755,1705;1915,1634;1943,1286;1741,1447;1670,1644;1589,1526;1731,1869;1800,1304;1297,1667;1573,1982;1638,1987;1447,1646;1501,1508;1716,1461;1319,1960;1228,1982;1484,1509;1243,1717;1589,1265;1173,1858;1173,1941;2007,1717;1915,1301;1719,1321;1511,1447;1758,1638;1779,1644;1904,1624;1460,1528;1798,1542;1773,1947;1621,1542;1710,1915;1663,2005;1573,1318;1643,1273;1643,1519;1748,1613;1693,1573;1987,2014;1196,1898;1982,1634;1542,1737;1849,1290;1800,1227;1960,1573;1704,1492;1601,1960;1297,1495;1573,1447;1952,1634;1463,1791;1910,1693;1800,1915;1960,1299;1887,1887;1520,1634;1257,1982;1708,1943;1395,1803;1569,1707;1152,1964;1646,1315;1331,1986;1173,1395;1308,1717;2024,2007;1492,1960;1705,1243;1965,1621;1235,1930;1429,1864;1798,1447;1545,1598;1960,1692;1495,1798;1160,1259;1646,1644;1960,1318;1634,1717;1469,1447;1704,1646;1981,1570;1211,1228;1915,1982;1391,1638;1741,1642;1936,1745;1621,1643;1717,1960;1296,1864;1928,1408;1735,1161;1277,1820;1211,1646;1906,1638;1737,1742;1687,1800;1491,1748;1603,1912;1542,1638;1447,1589;1830,1492;1880,1540;1378,1824;1277,1864;1160,1906;1888,1910;2002,1849;1423,1173;1293,1638;1460,1573;1441,1540;1979,1980;1205,1519;1603,1721;1573,1318;1395,1406;1798,1211;1386,1603;1634,1211;1587,1745;1364,1800;1395,1469;1762,1578;1866,1600;1638,1345;1717,1562;1621,1621;1329,1727;1447,1303;1638,1742;1514,1717;1981,1687;1910,1318;1803,1422;2005,1644;1887,1492;1779,1156;1194";
var nodesIds = nodesString.split(",");
var edgesSourceTargetIds = edgesString.split(",");
try
{
var vertexes = {};
nodesIds.forEach(function(nodeId) {
vertexes[nodeId] = graph.insertVertex(parent, null, nodeId, 0, 0, size, size);
});
edgesSourceTargetIds.forEach(function(edgesSourceTargetId){
var array = edgesSourceTargetId.split(";");
var sourceId = array[0];
var targetId = array[1];
var v1 = vertexes[sourceId];
var v2 = vertexes[targetId];
graph.insertEdge(parent, null, '', v1, v2);
});
organic.initialTemp = Math.sqrt(nodesIds.length) * size / 10;
organic.maxIterations = 20 * Math.sqrt(nodesIds.length);
organic.forceConstant = Math.max(size * 2, 50);
organic.maxDistanceLimit = organic.forceConstant * 2 * Math.sqrt(size);
organic.execute(parent);
}
finally
{
graph.getModel().endUpdate();
}
graph.fit();
if (mxClient.IS_QUIRKS)
{
document.body.style.overflow = 'hidden';
new mxDivResizer(container);
}
}
};
</script>
</head>
<!-- Page passes the container for the graph to the program -->
<body onload="main(document.getElementById('graphContainer'))" style="margin:4px;">
<!-- Creates a container for the graph with a grid wallpaper. Make sure to define the position
and overflow attributes! See comments on the adding of the size-listener on line 54 ff! -->
<div id="graphContainer"
style="position:absolute;overflow:auto;top:36px;bottom:0px;left:0px;right:0px;border-top:gray 1px solid;">
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment