Questions about handling graphs in Mathematica, graph theory, graph visualization, GraphPlot, the built-in Graph type and the Combinatorica` package.

learn more… | top users | synonyms (2)

9
votes
3answers
290 views

Preserving labels when using graph functions

I am finding that some functions that accept a graph and return a transformed graph lose all the vertex and edge labels of the graph being transformed. For example, when I define a graph like this: ...
9
votes
2answers
340 views

Transition between graphs

I want to visually demonstrate the manipulations made to a graph. For instance, I have a graph g where using the command ...
9
votes
2answers
303 views

VertexSize doesn't scale with Graph layout?

I wonder about how I could make a Graph scale automatically when I vary the size of the vertices. I would like to visualize information with a ...
9
votes
1answer
224 views

Possible improvements to this Syracuse (3x+1)/2 graph?

This algorithm produces the Syracuse disjoint tree graph without any duplicates. No need for Union, For, and ...
9
votes
1answer
729 views

When using GraphPlot with an adjacency matrix, how can I make Mathematica draw exactly one self loop for any non-zero weight?

I have tried using the option MultiedgeStyle->None, but apparently Mathematica doesn't treat self loops in the same way it treats edges. For example, I find ...
9
votes
1answer
845 views

How to add vertex/edge labels to existing graph

If I have already created a graph using Graph. Later, I want to add to the graph some vertex and/or edge labels, how can I do that? Thank you.
9
votes
2answers
227 views

Relaxation of Mass-Spring System with Pinned Masses

Problem Assume that four masses are connected to each other by springs while two of them are pinned down at their initial positions. Find the position of masses when system is at its minimum ...
9
votes
1answer
332 views

Caching of Graph Graphics

In this answer, Simon Woods concludes that when you display an expression with head graph more than once, something is getting stored somewhere. I looked into it too and found out this only happens if ...
9
votes
4answers
299 views

How can I efficiently check if a graph is unit distance?

A unit distance graph is a graph that is embeddable in the plane so that every edge has length 1. ...
9
votes
1answer
129 views

FindHamiltonianCycle is not invariant to edge permutation

Bug introduced in 9.0.1 or earlier and fixed in 10.0 Found this bug-like behaviour today: if the order of edges is changed so that VertexList does not return the ...
9
votes
1answer
615 views

How can I display a multigraph with different colored edges?

I'm new to Mathematica(version 9) and I'm trying to display a multigraph with different colored edges. Here's my code so far: ...
9
votes
1answer
135 views

How to get control over DepthFirstScan?

Is there a way to conditionally take control the flow during a depth-first scan against a TreeGraph? I have a tree graph whose nodes are constructed as object, and there's a method ...
9
votes
1answer
296 views

Binary decision diagrams (BDD)

I would like to use Mathematica to help me simplify a given Binary Decision Diagram (i.e. pick the optimal variable ordering). I don't seem to find anything at all on the topic, although it is ...
8
votes
3answers
593 views

How can one draw a network with nodes and links in a grid shape?

I'd like to be able to use MMa's graphics to make something like this which I know must absolutely be possible (and probably easy) with MMa. I don't actually even need different colors (though ...
8
votes
2answers
2k views

Dynamic graph visualisation using JLink/Java and GraphStream

Visualising the addition of new nodes and edges to a graph to 'watch it grow' is to something Mathematica is not suited to by default. However this type of animation really helps convey the emergence ...
8
votes
3answers
392 views

How to remove all dead ends from a undirected graph?

so what I want to do is take an undirected graph, and remove all the "dead ends" (that is, vertices that are attached to only one other vertex), but do it in such a way that it does it until reaches ...
8
votes
3answers
314 views

Pairwise distances of points and classification using GraphDistanceMatrix

The challenge Given $n$ points in $\mathbf{R}^3$ and a cutoff distance, $d$, I would like to determine all pairs of points that are separated by less than the given cutoff distance, $d$, and all ...
8
votes
4answers
342 views

Can I stop edges in graphs from drawing on top of the vertices?

Consider the following testadj = RandomVariate[BernoulliDistribution[0.15], {50, 50}]; AdjacencyGraph[testadj, VertexSize -> Large] The nodes are almost ...
8
votes
2answers
300 views

Organise a graph's vertices into levels

I would like to organise a graph's vertices in levels. Consider ...
8
votes
2answers
390 views

Efficient setting of properties of multiple vertices in Graph

The functions SetProperty and PropertyValue can only set a single property of a single vertex, as far as I know. How do I set a ...
8
votes
2answers
311 views

Is there a bug in FindClique?

If h is a graph, FindClique[g, {n}] should return a clique on exactly $n$ vertices if one exists in ...
8
votes
2answers
410 views

Graphing a network with state transition flows (of varying size)

In one of Stephen Wolfram's recent blog posts (http://blog.stephenwolfram.com/2013/04/data-science-of-the-facebook-world/#more-5350) he provides the network plot below. The size of the arrows that ...
8
votes
2answers
360 views

How do I convert this Nicomachus's Triangle to one with edges?

I want to put edges on this Nicomachus's Triangle r = 7; t = Table[2^(n - k) 3^k, {n, 0, r}, {k, 0, n}]; ColumnForm[t, Center] Is there an easy way to do this? ...
8
votes
3answers
471 views

Mathematica 10 Graph issue

fixed in 10.0.2 Please try to evaluate this code in Mathematica 10. ...
8
votes
2answers
280 views

Cases[data,Colon[key,_]] vs. Cases[data,key:_] toward XPath, XQuery

Exploring methods to index and search tree-structured key:value pairs via named-entity index (key paths) as opposed to Position-based indexing. Using Rule as ...
8
votes
2answers
131 views

Efficient solution for a discrete assignment problem with pairwise costs

Let's consider a simple graph with N vertices, and a corresponding set of N items. The goal of the problem is to assign every item to a vertex on the graph so that sum of a per-edge (that is ...
8
votes
2answers
3k views

How to find the Shortest Path, visiting ALL vertices, without coming back to the start (Hamiltonian Path, minimum distance)

A car has to pick up each person and take them to their destination. I am trying to find the shortest tour that will do this. How can I find the shortest path between any s and t.... visiting all ...
8
votes
4answers
3k views

How to generate and draw simple bipartite graphs?

A bipartite graph is a graph whose vertices can be divided into two disjoint sets. Given two lists: {1, 2, 3} and {x, y, z}, ...
8
votes
2answers
270 views

Creating a hyperlink graph from Wikipedia

This goes out to all the Mathematica experts - I'm hoping to get some helpful comments, ideas or code for that matter. In my attempts to maximize learning efficiency I had the idea to create an ...
8
votes
1answer
174 views

Using GraphHighlight interactively

I want to build a small GUI, where the user can select either a single edge or a single node of a graph. I got to this point: ...
8
votes
1answer
309 views

How can I sequentially apply different graph embeddings?

Imagine I have some graph G, and I perform a graph embedding using a command like: ...
8
votes
3answers
459 views

TreePlot with centered vertexes

I want to draw a tree plot for Euler totient function for this question like the following: I generate the EulerPhi for first 20 numbers into a list: ...
8
votes
1answer
198 views

Vertex merging in graph?

Given a Graph such as the one produced with the following code ...
8
votes
2answers
981 views
8
votes
1answer
536 views

Why does SocialMediaData return such a small FollowerNetwork?

I have hooked up my Twitter account to Mathematica and I have 1468 followers myfollowers = Length[SocialMediaData["Twitter", "Followers"]] 1468 I wondered what ...
8
votes
1answer
195 views

Enforce graph symmetry

I am using ...
8
votes
2answers
336 views

Finding All Chordless Simple Cycles In A Graph

I am doing a research on networks which consists of polygons with different number of sides. I am trying to find all simple cycles in a network which are chordless. As an example, consider the ...
8
votes
0answers
77 views

Graph: PropertyValue changes and Dynamic

I almost never work with Graph in Mathematica but lately I helped someone with it. For this, I tried to make an animation using ...
7
votes
5answers
420 views

Is there a neat way to generate the odd set constraints matrix?

Given a undirected graph $G=(V,E)$, I am trying to generate a related matrix $M$, where columns are indexed by $E(G)$ and rows are indexed by all odd subsets of $V(G)$. I can finish this task using ...
7
votes
2answers
521 views

Convert Graph to Graphics

In Mathematica 9, a graph is returned as an object with head Graph: In[8]:= CompleteGraph[8] // Head Out[8]= Graph ...
7
votes
3answers
308 views

Converting Mesh in Density Plots to a Graph

Consider the following line of code: ...
7
votes
3answers
2k views

Travelling salesman with start and end points for 30 points

I am doing a route optimisation for delivery vehicles and failing dismally. Please see problem statement below. My current solution uses FindShortestTour, but this does not have defined start and end ...
7
votes
5answers
614 views

Building graph based on the cities connection?

I built a Graph based on the permutations of city's connections from : ...
7
votes
3answers
466 views

I can't understand FindShortest Tour

I can't understand the function FindShortestTour because of the result: FindShortestTour[{ {0, 1}, {5, 1}, {2, 1}, {10, 1}}] ...
7
votes
3answers
709 views

Visualizing the output of a Voronoi diagram computation

I need to plot a graph (to be specific: Fortune Algorithm output) with given vertex coordinates and a few unconnected vertices. I am thinking of using Mathematica for that. ...
7
votes
2answers
1k views

Is it possible to export a graph as graphic to Excel?

It is straightforward to export lists to Excel with Export. Can I export a graphic image, too? This does not work: ...
7
votes
2answers
731 views

Controlling TreePlot (and GraphPlot) layout issue

A continuing battle with Mathematica involves graphics heavy with text labels. For example, the following expression renders so that the "Lifecycle properties..." ...
7
votes
3answers
322 views

Different colors for nodes in tree plot

I have some list of numbers which I am plotting using TreePlot. This is the code: ...
7
votes
3answers
774 views

Random Geometric Graphs

I'm trying to implement an application which uses random geometric graphs in Mathematica, but it seems Mathematica lacks the functionality. I need the following functionalities: Generate a set of ...
7
votes
2answers
532 views

Can I put tooltips in a Graph?

This doesn't work: Is there a way to do this? My real goal is to identify the second links in the graph below, which shows the results of a webcrawl (using this code). I'm open to another ...