New answers tagged

2

The new 12.1 EdgeTaggedGraph feels like a mess to be honest. The tags are not labels, so they don't visualize in the graph. In the example above you've hacked Labeled to do the labeling instead. The problem with that is that it seems to be incompatible with our ability to append or modify graphs. For instance, if one wanted to add a new edge with a new label ...


0

You can also use rules with patterns, e.g., VertexStyle -> {Alternatives@@lis2 -> Blue} when specifying options. This is particularly convenient for setting different options for multiple subsets of vertices/edges. For example, SeedRandom[1] SA = SparseArray[_ :> RandomInteger[1], {10, 10}]; AdjacencyGraph[lis1, SA, VertexLabels -> Placed["...


4

SeedRandom[0] NearestNeighborGraph[RandomReal[{0, 5}, {10, 2}], 2, VertexLabels -> {_ :> Last[vlist = RotateLeft[vlist]]}] Alternatively, SeedRandom[0] NearestNeighborGraph[vl = RandomReal[{0, 5}, {10, 2}], 2, VertexLabels -> Thread[vl -> vlist]] same picture and SeedRandom[0] Block[{i = 1}, NearestNeighborGraph[RandomReal[{0, 5}, {10, 2}...


3

You can specify VertexStyle directives using Style and use the form {Alternatives@@vlist1 -> optionvalue1, ...} for setting the values of other Vertex* options: HighlightGraph[GridGraph[{3, 3}], {Style[PathGraph[{3, 2, 1, 4, 7, 8, 9, 6, 5}], Red, Thickness[0.01]], Style[{3, 5}, Green, EdgeForm[{Purple, Opacity[1], Thickness[.02]}]]}, VertexSize -...


5

This input HighlightGraph[GridGraph[{3, 3}], {1, 2}, VertexSize -> .2,Style[{1, 2}, Blue]] is not valid syntax for HighlightGraph. VertexSize is an Option and so it must come after all the other arguments HighlightGraph[GridGraph[{3, 3}], Style[{1, 2}, Blue], VertexSize -> .2] Just for fun, here is another way you can modify properties of vertices ...


2

Here a potential way to illustrate the difference between wrapping and spanning clusters: (see the comments in the code for an explanation of what it does) replicateGraph[n_, g_] := VertexReplace[g, v_ :> v + #] &(* create copies of the graph with translated vertices *)/@ (ReverseSortBy[Abs]@Tuples[{-1, 0, 1}, {2}] (n - 1))(* translate the graph by ...


5

Ingest the data, make a matrix of the correlations, make a list with plant names: data = Get["~/Downloads/06krccza.txt"]; matData = data[[2 ;; -1, 2 ;; -1]]; lsPlantNames = Rest@data[[1]]; Length[lsPlantNames] (*70*) Make association of correlations and distances: aCors = Association@ Map[lsPlantNames[[#[[1]]]] -> #[[2]] &, Most[...


1

A more streamlined way to produce the matrices in OP (not an answer): ClearAll[toStates] toStates[t_, s_, m_] := Map[s[[Total[1 - UnitStep[t - #]]]] &, m, {2}] thresholds = {0, .5, 1., 1.5}; states = {s1, s2, s3}; m1S = toStates[thresholds, states, matT1]; m2S = toStates[thresholds, states, matT2]; {m1S, m2S} == {matT1S, matT2S} True maP[m1_, m2_, ...


1

I am not sure I understand the question. It seems to me that you can make the transition matrix by making the graph adjacency matrix row stochastic. Here is an example with question’s matT1: matT1rs = DiagonalMatrix[1/Total[matT1, {2}]].matT1; Total[matT1rs, {2}] (* {1., 1., 1., 1., 1.} *) MarkovProcessProperties[DiscreteMarkovProcess[{1, 0, 0, 0, 0}, ...


2

With faces defined as the list of 4-tuples in OP, we can construct a bipartite graph from faces to Union @@ faces using RelationGraph and use FindIndependentEdgeSet to find a matching: vlist = Union @@ faces; rg = RelationGraph[MemberQ, faces, vlist, ImageSize -> 900, VertexSize -> Tiny, ImagePadding -> {{100, 50}, {5, 5}}, VertexLabels -> ...


2

This answer avoids Inset altogether and grabs the graphics primitives from inside the expression from a system MoleculePlot3D, and is therefore a bit fragile because it could break in a future version that restructures the output from MoleculePlot3D. Inspection shows that the Graphics3D returned by MoleculePlot3D always contains a GraphicsComplex with all ...


0

Here's a simple function that can convert Graphics to a graph. With this, you can draw a simple graph with the Drawing Tools palette (http://reference.wolfram.com/language/tutorial/InteractiveGraphicsPalette.html) and then copy the graphics into this function: graphicsToGraph[gr : _Graphics | _Graphics3D] := Module[{ pts = Join @@ Cases[gr, Point[...


2

Give this a try and see if it does what you need: << GraphUtilities` GraphEdit[]


0

I wrote some code for drawing a graph interactively using DynamicModule and EventHandler. You can add vertices with right click and edges with left-click. The adjacency list is printed at the bottom. Admittedly, the graph is stored as a list of points (in the graphics object coordinates), not a Graph. Also, the style of the edges is fixed. DynamicModule[{...


Top 50 recent answers are included