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)

5
votes
3answers
304 views

How to extract edgeweights from a graph

I have a graph with weighted edges, and I'd like to obtain the edge weights of the edges in the graph. Is there a nicer way of doing this than getting the ...
3
votes
0answers
172 views

Is it possible to manipulate graphs by hand? [duplicate]

Possible Duplicate: Generating graphs interactively (GUI) If I plot a graph, is it possible for me to manipulate the vertices such that when I move them, their attached edges will follow. ...
25
votes
3answers
2k views

Finding all shortest paths between two vertices

The built-in FindShortestPath and GraphDistance functions find the shortest path between two particular vertices in a graph. I ...
21
votes
3answers
712 views

Finding a “not-shortest” path between two vertices

In designing a routine for making a simple three dimensional (5x5x5) labyrinth, I realized that my solutions (a solution is a labyrinth includes a single path from {1, 1, 1} to {5, 5, 5} in a 5 x5x5 ...
4
votes
1answer
216 views
17
votes
1answer
185 views

Is UndirectedEdge[a,b] the same edge as UndirectedEdge[b,a]?

Is UndirectedEdge[a,b] the same edge as UndirectedEdge[b,a]? Then please consider this. ...
8
votes
2answers
216 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 ...
9
votes
1answer
599 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
2answers
182 views

NumberOfSpanningTrees command not working correctly

I am attempting to use the Combinatorica NumberOfSpanningTrees command for all n-cycle graphs from 3 to 30. I am trying to get a ...
7
votes
2answers
382 views

Edge problems in a directed graph

I want to create the following two graphs. So far I tried the following Code ...
11
votes
2answers
1k views

Simple algorithm to find cycles in edge list

I have the edge list of an undirected graph which consists of disjoint "cycles" only. Example: {{1, 2}, {2, 3}, {3, 4}, {4, 1}, {5, 6}, {6, 7}, {7, 5}} Each ...
3
votes
1answer
200 views

Forcing a graph not to resize

This code: ...
4
votes
1answer
190 views

What's the most intelligent way to store the information of a selfmade graph?

I have a very long list of element, say $a1,a2, a3$,..., and they are all connected in that each is the child of many parents. E.g. $a74$ is associated with $a2,a55,a71$, and also contains ...
12
votes
2answers
254 views

Listing subgraphs of G isomorphic to SubG

If I have an undirected graph G, how could I write a function in Mathematica to obtain a list of subgraphs of G that are isomorphic to some other undirected graph SubG? I'd like to learn how to ...
20
votes
2answers
1k views

Cycles of length N in a graph

If I have an undirected graph represented with an adjacency matrix, how can I find all the subgraphs which are a cycle of length N? I don't really know the math nor the programming language well, so ...
18
votes
3answers
1k views

Generating graphs interactively (GUI)

I want to create graphs interactively using a GUI. I thought of using a ClickPane[] environment. The code I have (in part borrowed from the Documentation) works ...
16
votes
2answers
334 views

Packed Graph or GraphPlot output with non-square layout?

Graph or GraphPlot produce square layouts for disconnected graphs: Graph[Table[i -> Mod[i^3, 100], {i, 1, 100}]] I´d like to get a rectangular layout with ...
2
votes
2answers
395 views

How to impose custom style to the edges of a graph

We construct a graph as the following. ...
4
votes
1answer
151 views

HITS centrality

I want the centrality measure of a particular vertex in my graph, and for Closeness, Betweenness and Degree centralities I have been using : ...
6
votes
2answers
214 views

Truncate TreeForm to show only the top

For some expressions, TreeForm may grow very long. I'm only interested in the top levels of the expression. How can I get the tree form of only the first levels an ...
2
votes
1answer
157 views

VertexLabelStyle not found in Mathematica 8.0.0.0

I tried to use VertexLabelStyle, but seemed not recognized in my system with version number 8.0.0.0. Is this expected or I have missed something? From the online ...
8
votes
1answer
551 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.
4
votes
1answer
327 views

Get the neighboring vertices and incident edges from a vertex in a graph

I need to get the neighboring vertices and incident edges from a vertex in a graph. I assume NeighborhoodVertices can be used for the former. Anything better? Or ...
3
votes
1answer
700 views

How to write a function to add edges or vertex to a graph

I need to add either a vertex or an edge to a graph, and also sometimes, vertices or edges, or a mixture of the two. How to write a function for this?
16
votes
1answer
324 views

Convert GraphPlot[]s with many nodes into something that's human-understandable

This is more of an abstract/creative problem. I think everyone who has played around with GraphPlot, ended up with an image that looks like this, at least once in ...
10
votes
3answers
633 views

How to plot layered graphs?

Given a directed acyclic graph, there is always a possibility to plot the graph as layers, where nodes always send edges into one direction (usually down), to successive layers, and never backwards. ...
5
votes
3answers
291 views

Centrality measures for single nodes

I am producing a graph, generated by a list of adjacent nodes. (The list looks like {1 ->583, 1->2977, 2->14, 4->1293, 5->221, ...}. Each node of my ...
20
votes
2answers
1k views

How to plot planar graphs as such?

A planar graph is a graph that can be drawn in the plane such that no two edges cross. For example, the graph ...
5
votes
1answer
275 views

How to determine edgeweights from width of skeleton using MorphologicalGraph (or workaround)?

Background I'm trying to create a workaround for what seems to be a bug in MMA's graph functions related to edge weights: SO: How to Label Graph Edges with their weights According to MMA's ...
7
votes
1answer
819 views

Mathematica: Label specific vertices in GraphPlot

How can I label particular vertices in GraphPlot? And have the arrows space out accordingly, for the width of the label? I have Mathematica 7, but I think this question applies to all versions. ...
9
votes
4answers
427 views

Show path with arrows in a matrix

I have a matrix, for example, 5x5 matrix Partition[Range[25], 5]. And I am given a list, for example: ...
13
votes
4answers
359 views

How can I remove B -> A from a list if A -> B is in the list?

I have a list of transformations like this: list = {"A" -> "B", "B" -> "A", "C" -> "D"} As this is used to plot an undirected graph with ...
14
votes
3answers
2k views

How to generate random directed acyclic graphs?

How to programmatically build random directed acyclic graphs (DAG)? I know about the AcyclicGraphQ predicate and the ...
20
votes
1answer
625 views

Visualizing Rubik's Graph

After the August 2010 discovery that the diameter of the Rubik graph is 20, I wanted to make a way to visualize Rubik's graph. Since there are about $4.3 \times 10^{19}$ vertices in this graph, it is ...
8
votes
1answer
159 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: ...
9
votes
2answers
226 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 ...
3
votes
1answer
216 views

Implementing local complements of graphs

I'm trying to write a routine which generates the local complement of a graph at a vertex. For those who don't know, the local complement for a singly-connected, undirected graph is defined as the ...
15
votes
1answer
671 views

How to export and import Graphs with additional data?

I'm trying to export and then later import graphs with additional data added such as VertexLabels and EdgeLabels. When I export ...
21
votes
1answer
819 views

How to create regular (planar) graphs?

How to programmatically create and plot regular planar graphs with $k = 3, 4$ or $6$ (not hypercubes) and regular nonplanar graphs of $k = 8$ (see figure)? Note that what matters is the average ...
14
votes
3answers
208 views

What is the most convenient way to change options for Graph[] objects?

What is the most convenient way to change options such as VertexLabels in existing Graph objects? (Version 7 users note: ...
57
votes
3answers
1k views

Automatically generating a dependency graph of an arbitrary Mathematica function?

Has anyone written a function to pull the function dependencies of a function? That is, it would be nice to have a function that returns a list of function dependencies as a set of rules, terminating ...
4
votes
1answer
218 views

How do I find a weighted bipartite graph's minimum edge cover using Mathematica 8?

In graph theory, we use the Hungarian Algorithm to compute a weighted bipartite graph's minimum edge cover (a set of edges that is incident to every vertices, the one with the minimum total weight.) ...