New in Wolfram
Mathematica
8: Graph & Network Analysis
◄
previous
|
next
►
Application Areas
Topological Sorting
Using
Mathematica
8, it is easy to construct the condensation of a graph and then find a topological ordering of the strongly connected components. Compare adjacency matrices before and after reordering of vertices.
In[1]:=
X
g = \!\(\* GraphicsBox[ NamespaceBox["NetworkGraphics", DynamicModuleBox[{Typeset`graph = HoldComplete[ Graph[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}, { SparseArray[ Automatic, {20, 20}, 0, { 1, {{0, 3, 13, 15, 27, 30, 40, 53, 58, 60, 62, 66, 70, 75, 79, 87, 94, 98, 98, 101, 108}, {{5}, {12}, {19}, {1}, { 3}, {5}, {10}, {11}, {13}, {14}, {15}, {18}, {19}, { 10}, {18}, {1}, {2}, {3}, {5}, {8}, {9}, {10}, {11}, { 13}, {14}, {18}, {20}, {3}, {18}, {19}, {1}, {4}, {8}, { 9}, {10}, {11}, {13}, {15}, {17}, {19}, {1}, {2}, {3}, { 5}, {9}, {11}, {12}, {13}, {14}, {15}, {16}, {19}, { 20}, {1}, {3}, {10}, {18}, {19}, {3}, {18}, {3}, {18}, { 1}, {3}, {5}, {12}, {5}, {10}, {18}, {19}, {1}, {3}, { 10}, {12}, {18}, {12}, {13}, {17}, {19}, {3}, {4}, {5}, { 9}, {11}, {12}, {17}, {18}, {5}, {8}, {10}, {11}, {12}, { 14}, {18}, {5}, {10}, {12}, {13}, {10}, {11}, {12}, { 1}, {10}, {11}, {12}, {13}, {15}, {18}}}, Pattern}], Null}, {ImageSize -> 200}]], Typeset`boxes = GraphicsGroupBox[{{ Directive[ Hue[0.6, 0.2, 0.8], EdgeForm[ Directive[ GrayLevel[0], Opacity[0.7]]]], TagBox[ DiskBox[{0.7262585484991979, 1.072627586684525}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$1"], TagBox[ DiskBox[{1.0421544072259024`, 0.7785653225977971}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$2"], TagBox[ DiskBox[{2.12096600999724, 1.1871659169077557`}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$3"], TagBox[ DiskBox[{1.6698707883236314`, 1.2123925843281804`}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$4"], TagBox[ DiskBox[{0.938684823761077, 0.37688793493426753`}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$5"], TagBox[ DiskBox[{1.6513961891296332`, 1.8582119177282403`}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$6"], TagBox[ DiskBox[{1.2402279845315678`, 0.11750282973504289`}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$7"], TagBox[ DiskBox[{1.0956450604968655`, 1.8836653654001796`}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$8"], TagBox[ DiskBox[{2.7800689470296995`, 0.9029981483762035}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$9"], TagBox[ DiskBox[{1.0633563987464199`, 1.3997996138767181`}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$10"], TagBox[ DiskBox[{1.3950011140637197`, 0.5345761096449114}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$11"], TagBox[ DiskBox[{0.5774418134455355, 0.513058791773386}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$12"], TagBox[ DiskBox[{1.2694044773114714`, 1.1110026401065023`}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$13"], TagBox[ DiskBox[{0., 0.7535088278947915}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$14"], TagBox[ DiskBox[{1.9400005381008236`, 0.8045684229234294}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$15"], TagBox[ DiskBox[{0.4128690608694636, 0.09499623483805997}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$16"], TagBox[ DiskBox[{0.4794175421353717, 1.748221293844269}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$17"], TagBox[ DiskBox[{1.8176736366298614`, 0.4806044954105812}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$18"], TagBox[ DiskBox[{0.2956401289796545, 1.2450973926766953`}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$19"], TagBox[ DiskBox[{1.7111850660936696`, 0.}, 0.028641284424937324`], "DynamicName", BoxID -> "VertexID$20"]}, { Directive[ Opacity[0.7], Hue[0.6, 0.7, 0.5]], Arrowheads[{{0.029856842683540694`, 0.7}}], { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$12", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$19", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$1", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$10", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$11", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$13", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$14", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$15", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$19", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$3", Automatic, Center], { 2.0014074591049793`, 1.170528552768399}, { 1.9710789267244457`, 1.1670492694698709`}, { 1.9406181900316268`, 1.1650321406293531`}, { 1.9100956991685043`, 1.1644818314988599`}, { 1.8795820471032205`, 1.1653996148432881`}, { 1.8491478063613869`, 1.167783367996742}, { 1.818863365804671, 1.1716275777718745`}, { 1.7887987678341666`, 1.1769233532108871`}, { 1.3657549233338386`, 1.261976831998472}, { 1.3359797018947364`, 1.2687119249362808`}, { 1.3065627216569577`, 1.276870758328295}, { 1.277572018743704, 1.286434462277287}, { 1.2490746433762812`, 1.2973809176760311`}, { 1.2211365047991367`, 1.3096848073647747`}, { 1.1938222188437695`, 1.323317674685222}, { 1.1671949584840666`, 1.3382479892956076`}, DynamicLocation["VertexID$10", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$1", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$2", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$9", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$10", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$11", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$13", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$14", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$20", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$19", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$1", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$4", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$9", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$10", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$11", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$13", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$15", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$17", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$19", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$1", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$2", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$9", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$11", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$12", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$13", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$14", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$15", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$16", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$19", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$20", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$8", Automatic, Center], DynamicLocation["VertexID$1", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$8", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$8", Automatic, Center], DynamicLocation["VertexID$10", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$8", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$8", Automatic, Center], DynamicLocation["VertexID$19", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$9", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$9", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$10", Automatic, Center], { 1.1829149496386806`, 1.4164369780160753`}, { 1.2132434820192142`, 1.4199162613146035`}, { 1.2437042187120333`, 1.4219333901551214`}, { 1.2742267095751558`, 1.4224836992856145`}, { 1.3047403616404396`, 1.4215659159411862`}, { 1.3351746023822733`, 1.4191821627877323`}, { 1.3654590429389892`, 1.4153379530125996`}, { 1.3955236409094935`, 1.4100421775735872`}, { 1.8185674854098215`, 1.3249886987860022`}, { 1.8483427068489238`, 1.3182536058481935`}, { 1.8777596870867024`, 1.3100947724561793`}, { 1.906750389999956, 1.3005310685071874`}, { 1.935247765367379, 1.2895846131084432`}, { 1.9631859039445234`, 1.2772807234197}, { 1.9905001898998906`, 1.2636478560992526`}, { 2.0171274502595935`, 1.2487175414888667`}, DynamicLocation["VertexID$3", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$10", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$11", Automatic, Center], DynamicLocation["VertexID$1", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$11", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$11", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$11", Automatic, Center], DynamicLocation["VertexID$12", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$12", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$12", Automatic, Center], DynamicLocation["VertexID$10", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$12", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$12", Automatic, Center], { 0.5206197882338195, 0.5799556495921685}, { 0.5066605851797732, 0.5972143728211748}, { 0.49354728718159996`, 0.6151242665397497}, { 0.48131022291175235`, 0.6336439084222257}, { 0.4699776944734902, 0.6527304659063694}, { 0.45957591194326497`, 0.6723397952573044}, { 0.45012893275158194`, 0.6924265436639392}, { 0.4416586060425394, 0.7129442541317673}, { 0.3289379322561872, 1.0057596944930909`}, { 0.3214638483543828, 1.026660913290767}, { 0.3150032934560556, 1.0478972997019538`}, { 0.30957120964926027`, 1.0694197378286043`}, { 0.3051801603555352, 1.0911784501870967`}, { 0.3018403012729949, 1.1131231128344996`}, { 0.2995593568880473, 1.1352029717586936`}, { 0.2983426026100627, 1.1573669602631695`}, DynamicLocation["VertexID$19", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$13", Automatic, Center], DynamicLocation["VertexID$1", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$13", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$13", Automatic, Center], DynamicLocation["VertexID$10", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$13", Automatic, Center], DynamicLocation["VertexID$12", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$13", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$14", Automatic, Center], DynamicLocation["VertexID$12", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$14", Automatic, Center], DynamicLocation["VertexID$13", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$14", Automatic, Center], DynamicLocation["VertexID$17", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$14", Automatic, Center], DynamicLocation["VertexID$19", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$15", Automatic, Center], DynamicLocation["VertexID$3", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$15", Automatic, Center], DynamicLocation["VertexID$4", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$15", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$15", Automatic, Center], DynamicLocation["VertexID$9", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$15", Automatic, Center], DynamicLocation["VertexID$11", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$15", Automatic, Center], DynamicLocation["VertexID$12", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$15", Automatic, Center], DynamicLocation["VertexID$17", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$15", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$16", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$16", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$16", Automatic, Center], DynamicLocation["VertexID$10", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$16", Automatic, Center], DynamicLocation["VertexID$11", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$16", Automatic, Center], DynamicLocation["VertexID$12", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$16", Automatic, Center], DynamicLocation["VertexID$14", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$16", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$17", Automatic, Center], DynamicLocation["VertexID$5", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$17", Automatic, Center], DynamicLocation["VertexID$10", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$17", Automatic, Center], DynamicLocation["VertexID$12", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$17", Automatic, Center], DynamicLocation["VertexID$13", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$19", Automatic, Center], DynamicLocation["VertexID$10", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$19", Automatic, Center], DynamicLocation["VertexID$11", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$19", Automatic, Center], { 0.3524621541913706, 1.178200534857913}, { 0.3664213572454168, 1.1609418116289065`}, { 0.3795346552435901, 1.1430319179103314`}, { 0.3917717195134377, 1.1245122760278556`}, { 0.40310424795169986`, 1.105425718543712}, { 0.413506030481925, 1.0858163891927768`}, { 0.42295300967360816`, 1.065729640786142}, { 0.4314233363826506, 1.045211930318314}, { 0.5441440101690029, 0.7523964899569905}, { 0.5516180940708073, 0.7314952711593143}, { 0.5580786489691345, 0.7102588847481276}, { 0.5635107327759299, 0.6887364466214771}, { 0.5679017820696548, 0.6669777342629847}, { 0.5712416411521952, 0.6450330716155819}, { 0.5735225855371429, 0.6229532126913877}, { 0.5747393398151275, 0.6007892241869117}, DynamicLocation["VertexID$12", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$20", Automatic, Center], DynamicLocation["VertexID$1", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$20", Automatic, Center], DynamicLocation["VertexID$10", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$20", Automatic, Center], DynamicLocation["VertexID$11", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$20", Automatic, Center], DynamicLocation["VertexID$12", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$20", Automatic, Center], DynamicLocation["VertexID$13", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$20", Automatic, Center], DynamicLocation["VertexID$15", Automatic, Center]}]}, { Arrowheads[0.029856842683540694`], ArrowBox[{ DynamicLocation["VertexID$20", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}]}}}]}, DynamicBox[GraphComputation`NetworkGraphicsBox[ 1, Typeset`graph, Typeset`boxes], { CachedValue :> Typeset`boxes, SingleEvaluation -> True, SynchronousUpdating -> False, TrackedSymbols :> {}}, ImageSizeCache->{{1.5599999999999996`, 126.43999999999998`}, {-45.54239999999997, 40.5161598315304}}]]], DefaultBaseStyle->{ "NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]}, FrameTicks->None, ImageSize->{129., Automatic}]\);
In[2]:=
X
components = ConnectedComponents[g];
In[3]:=
X
edges = Union[ Cases[EdgeList[g] /. Table[v -> First[Select[components, MemberQ[#, v] &]], {v, VertexList[g]}], u_ \[DirectedEdge] v_ /; u =!= v]];
In[4]:=
X
cond = Graph[components, edges];
In[5]:=
X
h = Graph[Join @@ TopologicalSort[cond], EdgeList[g], Options[g]];
In[6]:=
X
GraphicsGrid[({#, ArrayPlot[AdjacencyMatrix[#]]} & /@ {g, h})\[Transpose], ImageSize -> 400]
Out[6]=