New answers tagged

0

Jason probably has answer you need but I choose to take a blindingly simple interpretation of the question, and offer: GraphPlot[ {1 -> 2, 2 -> 1, 3 -> 1, 3 -> 2, 4 -> 1, 4 -> 2, 4 -> 4} , VertexLabeling -> True ] /. {4, 1} -> Sequence[] For the second question you should be able to use either VertexRenderingFunction or ...


6

If you have a GraphPlot, then it is simply a Graphics object, and you can't do any of the interactive things you can do with a Graph. Look here for info on the differences between the two functions. If you want the vertices for the second GraphPlot to have the same coordinates as the first, then you need to specify the VertexCoordinateRules. To do this, ...


7

If you need to compute diameters for large graphs, you should be aware that GraphDiameter tends to use an unreasonable amount of memory (up to gigabytes). Based on its memory use, I believe that it computes the complete GraphDistanceMatrix first, and then just takes the largest element. I have reported this to WRI on Feb 13 this year, and support ...


5

Hiding behind Details and Options on the documentation page is Method Automatic Method to use and Possible Method Settings include "Dijkstra", "FloydWarshall", "Johnson", and "PseudoDiameter".


5

What you are looking for is called isomorphism for coloured graphs. Both vertices and edges may be "coloured" with colours chosen from a discrete set, and only those isomorphisms are admitted which map a vertex (or edge) into another one that has the same colour. Using edge/vertex weights for this is not really appropriate. These properties are meant to ...


2

Mathematica automatically set vertex shape to point when graph is large. You can reset vertex shape to "Circle": GraphDrawing = SetProperty[ TestGraph, {VertexSize -> VertexSizeRules, VertexShapeFunction -> "Circle", ImageSize -> 600}]


2

Rough mock up of how you could handle this, using Vikram's suggestion to import the data: In[4]:= lis=ReadList["yourfileName.ncol", Word, RecordLists->True, WordSeparators->{" "}] (*Out[4]= {{"0000001", "0000000", "0.4408587960080000"}, {"0000002", "0000000", "0.7405196230980000"}, {"0000002", "0000001", "0.5211728712080000"}, {"0000003", "0000000", ...


1

Seems in Mathematica 10 you should use the VertexLabels option. So, your code can be written like this: Graph[{1, 2, 3, 4, 5, 6}, {1 -> 2, 1 -> 3, 2 -> 5, 2 -> 6, 5 -> 6}, VertexLabels -> "Name"] Which will give the result shown below:


1

As pointed out by @Szabolcs in the comments to the question, I was trying to do something stupid. I figured I should write it up in case anyone else comes across this. GraphDistance tries to find the minimal sum of weights of edges between two points for a weighted graph. Therefore it doesn't make sense to use complex weights, as mathematica will not be ...


3

Solution based on the GridGraph SeedRandom[10801]; dimension = 20; coDimension = 30; percProbability = 0.7; deleteMe = Pick[Table[i, {i, dimension*coDimension}], Table[RandomReal[] > percProbability, {i, dimension*coDimension}]]; G = GridGraph[{dimension, coDimension}, VertexLabels -> "Name", ImagePadding -> 30]; G = ...


0

The solution for the GridGraph here. You need to fix the VertexCoordinates before deletions. G = SetProperty[G, VertexCoordinates -> GraphEmbedding[G]]; VertexDelete[G, deleteMe]


6

Big Thank You to Szalbocs! You need to have G = SetProperty[G, VertexCoordinates -> GraphEmbedding[G]]; just before VertexDelete[G, deleteMe] SeedRandom[10801]; dimension = 5; coDimension = 10; percProbability = 0.7; deleteMe = Pick[Table[i, {i, 1, 30}], Table[RandomReal[] > 0.5, {i, 30}]]; G = GridGraph[{dimension, coDimension}, ...


7

Here's a solution using MorphologicalGraph[]: SeedRandom[10801]; dimension = 100; coDimension = 30; percProbability = 0.7; myData = Table[Table[Boole[RandomReal[] < percProbability], {i, dimension}], {j, coDimension}]; img = Binarize@Image@myData; Now all you need to do is use FindShortestPath[]. For example, the shortest path from top-left ...


2

It is because MinimumVertexColoring is from the old Combinatorica package, and the data format of Graph is different from the new Graph in V10. To fix this problem, you will need to convert the new atomic graph object to the old representation. Needs["Combinatorica`"]; Needs["GraphUtilities`"]; g = System`RandomGraph[{5, 6}]; cg = ToCombinatoricaGraph[g]; ...


5

ssch's answer is very helpful. However, there is another possibility to introduce a length scale (which I prefer), namely VertexSize -> {"Scaled",.1} as described by the documentation article VertexSize. This determines how large a vertex is given in units, where the "overall diagonal" of the graph equals 1. Many of the times, this is very similar to ...


3

You can use vertexDeleteKeepEmbedding which is a side effect of Clickable graph answer: gr = CompleteGraph[17, PlotRange -> 2] FoldList[ vertexDeleteKeepEmbedding, gr, RandomSample @ Most @ VertexList @ gr ] // ListAnimate vertexDeleteKeepEmbedding[graph_, vertex_] := Module[{ coords, vertices = VertexList[graph] } , coords = ...


2

GraphData[5] returns a list of specifications of graphs with 5 vertices. Apply GraphData again to such a specification to get an actual graph. For example, GraphData[{"Wheel", 5}] where {"Wheel", 5} is the last element from GraphData[5]. The GraphData documentation page has many such examples.


4

This IS NOT A BUG but do IS A BUG as well. This is not a BUG at first, but I found a serious BUG while trying to persuade @yode it's not a BUG. I think I've got an explanation for this problem: First thing first, Let's first check our documentation: It said that when setting EdgeCost to Automatic cost per unit flow on an edge is taken to be 1. Thus we ...



Top 50 recent answers are included