# Tag Info

5

Graph will not be unique unless you specify some other properties. Here VertexList order is important. Compare: g = RandomGraph[{10^4, 10^6}]; FindGraphCommunities[g] == FindGraphCommunities[Graph[EdgeList[g]]] False FindGraphCommunities[g] == FindGraphCommunities[Graph[VertexList[g], EdgeList[g]]] True So now when you know how to get ...

3

For the specific example in the question, this generates the adjacency matrix in about 20ms for nS = 1000: {a, b} = List @@ Transpose[aList]; adjMat2 = UnitStep[Abs@Outer[Plus, -b, b] ~Subtract~ Outer[Plus, -a, a]] ~BitXor~ 1 If you have lots of different edge functions to play with and don't want to work out a different optimised algorithm for each one, ...

5

Here's a start, about fifteen times faster in my limited tests on a case of 2000... (aList, etc. setup same as yours, you can throw the pieces to parallel kernels, of course, particularly the mapping from tuples to rules which is >80% of the time used in below). i1 = Join @@ Table[ConstantArray[i, i], {i, 1, nS}]; i2 = Join @@ Table[Range[1, j], {j, 1, ...

0

Here's how to write the results to file as they are found. I can't be sure if this will solve your memory problem as I have not run it for long enough. The original code uses Sow to collect the results. All that is required is to replace Sow with a Write statement, plus code to open and close the file stream. I have also made a couple of other minor ...

0

Here's a completely contrived example that gets to the gist of my comment. I store the "logic" of the nested If as custom vertex properties, and simply follow the results, highlighting the appropriate edges. Clearly, code can use the results for control of flow, and that flow can be visualized with the graph. If you really wanted to do this kind of thing, ...

7

Fixing the edge length makes the problem harder. Otherwise, maybe this here gives an idea << ComputationalGeometry data = .9 Flatten[ Table[{x, y} + .07 RandomReal[{-1, 1}, {2}], {x, -1, 1, .2}, {y, -1, 1, .2}], 1]; delval = DelaunayTriangulation[data]; convexHull = ConvexHull[data]; gr = DiagramPlot[data, ##, LabelPoints -> False] ...

1

As @rm-rf said in the comments, you need to use RuleDelayed (i.e. :> instead of ->) to ensure that Graph evaluates only after the substitutions have been made. There is a little subtlety here: you may have assumed that Graph does not evaluate to anything, it is simply a representation of a graph, the same way as Graphics is just a representation of ...

0

Combinatorica is mostly obsoleted by version 8's built-in Graph data structure and the related functions. Do not load Combinatorica in v8 or later, unless you need functionality that is not available built-in and you know how to work around the name conflicts between Combinatorica and built-in functions. In this case just use ConnectedGraphQ[gp]

2

This is the way to do it if you really need to use the Combinatorica package: << Combinatorica gpc = CombinatoricaFromOrderedPairs[{{1, 3}, {1, 2}, {3, 1}}]; CombinatoricaStronglyConnectedComponents[gpc] (* {{1, 3}, {2}}*)

2

Let me give you an outline. First and as discussed in chat I change your tree data-structure a bit to make it smaller. A tree with a root r and two children a and b is now represented as r[a,b] which is a natural representation in Mathematica. To create a tree like you showed I use a function Node which does the job. Node[root_, {args__}] := root[Sequence ...

Top 50 recent answers are included