New answers tagged

2

To see geng's options, just rung geng -h on the command line. You can use something like this to e.g. generate connected graphs (-c) on 5 vertices (5) with 6 to 7 edges (6:7): geng = StartProcess[{"/opt/local/bin/geng", "-c", "5" , "6:7"}] This does generate all graphs without stopping. But we can read them into Mathematica one by one instead of reading ...


1

The nauty tool includes the program geng which can generate all non-isomorphic graphs with various constraints (including on the number of vertices, edges, connectivity, biconnectivity, triangle-free and others). Its output is in the Graph6 format, which Mathematica can import. For example, assuming you have geng installed in /opt/local/bin, Import["!/opt/...


2

(This answer is basically the same as @kglr's, but avoids post-processing and includes a discovery mechanism.) You can use the "Options" discovery mechanism to find out the options supported by a particular graph element: GraphElementData["ShortFilledArrow", "Options"] {"ArrowSize" -> Automatic, "ArrowPositions" -> Automatic} Your desired Arrowheads ...


2

LayeredGraphPlot[edges, Left, EdgeShapeFunction -> ({Black, If[MemberQ[{"vertex5"}, Last@#2], Line@#, GraphElementData[{"ShortFilledArrow"}][##]]} &)] To change the size and/or position of the arrow glyph you can use: LayeredGraphPlot[edges, Left, EdgeShapeFunction -> ({Black, If[MemberQ[{"vertex5"}, Last@#2], Line@#, ...


5

communities = GatherBy[VertexList[g], PropertyValue[{g, #}, VertexStyle] &]; CommunityGraphPlot[g, communities, VertexStyle -> PropertyValue[g, VertexStyle]] Add the option Method -> "Hierarchical" to get


5

When you construct a Graph using the syntax Graph[edgelist, options] the list of vertices is taken from the edges. Using this syntax it would be impossible to add an edge-less vertex. When you refer to this nonexistent vertex in the VertexLabels option, it is an error. Then Graph fails to give a message and return unevaluated. Use this syntax instead, ...


4

Update: ClearAll[grapH, combinedGraph] grapH[mat_, dir_: "Column"][t_, v_, opts : OptionsPattern[Graph]] := Module[{vertices = CharacterRange["A", "Z"][[;; Length@mat]], comp = dir /. {"Column" -> VertexInComponent, "Row" -> VertexOutComponent}, gf = dir /. {"Column" -> AdjacencyGraph, "Row" -> ReverseGraph@*AdjacencyGraph}, g}...


3

You can use older GraphPlot. In version 12.0, it is renamed GraphComputation`GraphPlotLegacy. GraphComputation`GraphPlotLegacy[{{1 -> 2, "a"}, {1 -> 2, "b"},{2 -> 1,"c"}}, DirectedEdges -> True, VertexLabeling -> True]


4

You can also use CommunityGraphPlot[g, VertexStyle -> PropertyValue[g, VertexStyle]]


0

> CommunityGraphPlot[g, VertexStyle -> {NS | N1 | NS | N11 | NS | N18 > | NS | N24 | NS | N27 | > NS | N35 | NS | N37 | N1 | N4 | N1 | N5 | N1 | N6 | N1 | N7 | > N1 | N8 | N1 | N9 | N2 | N5 | N3 | N5 | N3 | N15 | N4 | N2 -> > Red, N4 | N3 | N4 | N5 | N4 | N12 | N4 | N13 | N4 | N14 | N5 | > N15 | N5 | N16 | N5 |...


6

You can use rules for setting values for the option VertexSize : Graph[e, VertexSize -> {v_ -> .6, v_ /; Length[v] === 4 -> .9}, PerformanceGoal -> "Quality", DirectedEdges -> True, VertexLabels -> Placed["Name", Center], ImageSize -> 1500, BaseStyle -> {"Arrowheads" -> .009}] Alternatively, Graph[e, VertexSize -> {v_ :&...


5

Clear["Global`*"] e = {{M1, W1} -> {M1, M2, W1, W2}, {M1, W2} -> {M1, M2, W1, W2}, {M1, W3} -> {M1, M3, W3, W4}, {M1, W4} -> {M1, M3, W3, W4}, {M2, W1} -> {M1, M2, W1, W2}, {M2, W1} -> {M2, M3, W1, W2}, {M2, W2} -> {M1, M2, W1, W2}, {M2, W2} -> {M2, M3, W1, W2}, {M2, W3} -> {M2, M3, W3, W4}, {M2, W4} -> {...


6

One possibility is to use a VertexShapeFunction whose size depends on the length of the vertex name: Graph[ e, PerformanceGoal->"Quality", DirectedEdges->True, VertexLabels->Placed["Name",Center], ImageSize->1500, BaseStyle->{"Arrowheads"->.009}, VertexShapeFunction->Function@{Disk[#, Length[#2]/8.5], Text[#2,...


4

The GraphEmbedding function. ${}$


2

You can modify the Arrowheads setting by giving Graph a BaseStyle option: e = {{M1, W1} -> {M1, M2, W1, W2}, {M1, W2} -> {M1, M2, W1, W2}, {M1, W3} -> {M1, M3, W3, W4}, {M1, W4} -> {M1, M3, W3, W4}, {M2, W1} -> {M1, M2, W1, W2}, {M2, W1} -> {M2, M3, W1, W2}, {M2, W2} -> {M1, M2, W1, W2}, {M2, W2} -> {M2, M3, W1, ...


4

Reversing the graph and reformatting the nodes should get you started: ClearAll[hasseF] vf[{xc_, yc_}, name_, {w_, h_}] := Text[Grid[name, Dividers -> {False, True}], {xc, yc}]; hasseF = ReverseGraph@*TransitiveReductionGraph@*RelationGraph hasseF[ SubsetQ, Subsets[{{M1, W1}, {M1, W2}, {M2, W1}, {M2, W2}}], VertexShapeFunction -> vf ] Edit: @...


Top 50 recent answers are included