Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
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,...


6

You can use VertexSize and VertexStyle (suggested by Szabolcs in comments) in two ways: SetProperty[G, {VertexSize -> Thread[VertexList[G] -> ls], VertexStyle -> Thread[VertexList[G] -> (ColorData["Rainbow"] /@ Rescale[ls])]}] or SetProperty[G, {VertexSize -> {v_ :> ls[[v]]}, VertexStyle -> {v_ :> (ColorData["Rainbow"]@...


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} -> {...


4

A few additional alternatives: VertexInComponent Rest @ VertexInComponent[edges, 5,1] {27, 23, 22, 21, 4, 25, 7, 24, 30, 15, 18, 19, 29, 3, 8, 9, 10} GroupBy GroupBy[edges, Last -> First] @ 5 {27, 23, 22, 21, 4, 25, 7, 24, 30, 15, 18, 19, 29, 3, 8, 9, 10} ReplaceAll Rest @ DeleteDuplicates[5 /. List /@ Reverse /@ edges] {27, 23, 22, 21, 4, ...


4

Simple pattern matching: Cases[edges, edge : (v_ -> 5) :> v] {27, 23, 22, 21, 4, 25, 7, 24, 30, 15, 18, 19, 29, 3, 8, 9, 10} If you had specified the graph using DirectedEdge instead, then the pattern would have looked like this: Cases[DirectedEdge @@@ edges, edge : DirectedEdge[v_, 5] :> v] {27, 23, 22, 21, 4, 25, 7, 24, 30, 15, 18, 19, 29,...


4

SeedRandom[1] mt = RandomInteger[1, {20, 50}]; gg = GridGraph[Dimensions[mt]]; An alternative approach to align the GridGraph and MatrixPlot outputs is to use the options DataRange and DataReversed with MatrixPlot: Show[MatrixPlot[mt, DataReversed -> True, DataRange -> Thread[{1, Reverse@ Dimensions[mt]}]], gg] We can remove from gg the vertices ...


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: @...


4

The GraphEmbedding function. ${}$


3

You could try using "MultipartiteEmbedding" as the vertex layout method, and perhaps adjust vertex partitions accordingly. Here is a stab at it: graphData = KeyValueMap[Labeled[#2["From"] -> #2["To"], #1] &] @ Association @ streams; Graph[ graphData, VertexShapeFunction -> "Square", VertexSize -> Large, VertexLabels -> Placed["Name", ...


2

dims = {4, 4}; (* e.g. 16 nodes *) grid = GridGraph[dims]; xyNodes = AbsoluteOptions[grid, VertexCoordinates][[1, 2]] - 0.5 g = GridGraph[dims, VertexCoordinates -> xyNodes, EdgeStyle -> Gray]; info = RandomChoice[{0, 1}, dims]; (* fake data for bipartite graph *) Show[{MatrixPlot[info], g}] For more illustrative fake data and deleted edges: ...


2

Outer[Total[AdjacencyMatrix[g][[#, #2]], 2] &, SCCs, SCCs, 1] {{0, 0, 0, 0}, {1, 0, 0, 0}, {0, 0, 0, 0}, {1, 5, 3, 30}} or Outer[Length[AdjacencyMatrix[g][[#, #2]]["NonzeroPositions"]] &, SCCs, SCCs, 1] {{0, 0, 0, 0}, {1, 0, 0, 0}, {0, 0, 0, 0}, {1, 5, 3, 30}} or ecounts = Outer[EdgeCount[g, DirectedEdge[Alternatives @@ #, Alternatives @@ #...


2

One potential bottleneck is incidv = Flatten[Position[edges, (v \[UndirectedEdge] _ | _ \[UndirectedEdge] v)]] as it involves (i) a search in the rather long list of edges and (ii) pattern matching, which both tend to be rather slow. A quicker way will be to compute all these lists at once via vertexedgeincidences = IncidenceMatrix[G]["AdjacencyLists"]; ...


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, ...


2

A custom layout combining grid embedding and multipartite embedding: ClearAll[multipartiteOnGrid] multipartiteOnGrid[{r_, c_}, columnpositions_] /; c == Length @ columnpositions := Module[{grd = Partition[Tuples[Range /@ {c, r}], r], prts = columnpositions /. {All -> r, i_Integer?Negative :> r + 1 + i} /. Span[a_, b_] :> Range[a, b]}, ...


2

coords = Transpose[Total[mm, {#}] & /@ {2, 1}]; rules = MapIndexed[# -> #2[[1]] &, coords]; You can separate the input list into two groups using GroupBy and use PlotStyle to style each group: lists = Values @ GroupBy[rules, MemberQ[sccLargest, Last@#] &]; ListPlot[lists, AspectRatio -> 1, PlotRange -> {{-0.05, maxRange}, {-0.05, ...


1

ClearAll[edgeW, gr, m, n, mm, sa, wG, paths, pathMult, sccL, grSCCl]; n = 17; edgeW = Module[{g = #, e = DirectedEdge @@@ Partition[#, 2, 1] & /@ FindPath[##, ∞, All]}, Transpose[{e, PropertyValue[{g, #}, EdgeWeight] & /@ # & /@ e}]] &; Manipulate[SeedRandom[1245]; mm = RandomReal[1, {n, n}]; gr = RandomGraph[{n, m}, DirectedEdges -...


1

You could use Style wrapper with MapAt: ListPlot[MapAt[Style[#[[1]], Red] -> #[[2]] &, Table[{cau[[i]], eff[[i]]} -> i, {i, 1, n}], List /@ sccLargest], AspectRatio -> 1, PlotRange -> {{-0.05, maxRange}, {-0.05, maxRange}}, PlotStyle -> PointSize[Large], PlotTheme -> "Detailed", GridLinesStyle -> LightGray, ...


1

You could use Epilog. epilog = Table[{cau[[i]], eff[[i]]} -> i, {i, 1, n}] // Select[MemberQ[{3, 4, 9, 10, 11, 14, 15}, Last@#] &] // Map[{PointSize[Large], Red, Point[First@#]} &]; ListPlot[Table[{cau[[i]], eff[[i]]} -> i, {i, 1, n}], AspectRatio -> 1, PlotRange -> {{-0.05, maxRange}, {-0.05, maxRange}}, PlotStyle -> ...


1

Manipulate[sgb = subgraphBetween[θ1, θ2]; sccLargest = MaximalBy[Length] @ ConnectedComponents[sgb] // Flatten; Grid[{{"Digraph within the interval for " <> ToString[Subscript[m, ij], TraditionalForm] <> "\nsubgraph - largestCC", "Total number of edges in the interval (subgraph)", "Histogram (subgraph)"}, {...


1

vprops = {{2, 4, 7}, {1, 4, 1}, {2, 4, 1}, {0, 4, 1}, {6, 1, 7}, {4, 0, 1}}; rules = Thread[VertexList[g] -> vprops]; You can use rules with ReplaceAll: conn[[4]] /. rules {{1, 4, 1}, {2, 4, 1}, {0, 4, 1}} %[[All, 1]] {1, 2, 0} Total @ % 3 Alternatively, construct an Association using VertexList[g] and vprops: assoc = AssociationThread[...


Only top voted, non community-wiki answers of a minimum length are eligible