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)

20
votes
1answer
1k views

How to divide the wine into two equal portions

There is a 8-liter bottle is full of wine. There are two empty bottles that have capacity 5-liters and 3-liters. How can these three bottles be used to separate the wine into two 4-liter portions? ...
3
votes
1answer
47 views

Use (network) graph as vertex

I have a Markov chain with graphs as the states. Basically how one network structure would evolve to another in the next period. To avoid confusion, I'll use the term "network" instead of "graph". I ...
0
votes
0answers
62 views

Enumerating all orientations of an undirected graph

Given an undirected graph $G$, an orientation of $G$ is a directed graph obtained by assigning every edge a direction, a superorientation of $G$ is a directed graph obtained by orienting every edge in ...
2
votes
2answers
114 views

How to extract the structure of relationships amongst variables in a system of equations? [closed]

Mathematica being a CAS, I would have thought what I'm trying to do a natural task. But I have not been able to find any information on this in the Internet. Basically, I have a large collection of ...
0
votes
0answers
21 views

Different edge Weights for edge Graph

I have a weighted Grid Graph with Diagonal Edges (nXm). I want to add different cost to the parallel edges. All Horizontal(0°-->) will have edgeweight of 1.8 All Horizontal(180°<--) will have ...
1
vote
1answer
48 views

How to make a disconnected graph to be 1-edge-connected(but not 2-edge-connected) with some shortest edge

Assume I have a graph.You can run following code to get it. Import["http://goo.gl/NaH6rM"]["http://i.stack.imgur.com/EyAKW.png"] It is a disconnected graph.But ...
10
votes
4answers
243 views

Tom's family how to cross the bridge

A interesting question.Tom's family just have a flashlight which will extinguish after 30 seconds.They wanna go through a bridge to arrive opposite side with the flashlight.But as the picture,they ...
1
vote
1answer
63 views

DirectedEdges -> False not working

Consider this graph, that I downloaded from the OpenConnectome project. Graph[EdgeList[cElegans], DirectedEdges -> False] // DirectedGraphQ outputs: ...
2
votes
1answer
102 views

How to find the shortest path going through some specified vertices

I have a grid graph g = GridGraph[{12, 12}, VertexLabels -> "Name"] We can find a shortest from 1 to 144 ...
0
votes
1answer
67 views

How do I display a graph theory problem? [closed]

If I have several nodes and the distances that they have between one another, how do get Mathematica to display this as a graph? And also maybe define this graph in such a way that I can then use ...
1
vote
1answer
112 views

Import graphml file in mathematica

I am trying import a graphml file I created with NodeXL in mathematica in order to create a network. However when i try to import it I get the error message: "Cannot import data as GraphML format". ...
3
votes
0answers
31 views

WeightedAdjacencyMatrix does not complete for Connected Graph

Please see code snippet below - I have a weighted, connected graph that models a software process using a DiscreteMarkovProcess. I set some of the edge weights to ...
4
votes
1answer
147 views

The algorithm of ListGraphs[n,m]

I'm not sure if this is a Mathematica problem, math problem or a CS problem, so if this is off-topic please transfer it. In the package Combinatorica there is a ...
1
vote
0answers
59 views

How-to make large graph more readable?

One day, I found myself curious about different topics in mathematics. So, I stumbled uppon a website (considerably old website) where author has tabularized mathematics into subjects and associated ...
4
votes
4answers
120 views

GridGraph with diagonal edges

I have n x n GridGraph (or n x m), I trying to add diagonal edges for each square box automatically and then assign same weights to the diagonals, same weights to horizontal edges and same weights to ...
3
votes
3answers
83 views

Reverse the layout when using “DiscreteSpiralEmbedding”

I have a graph such as NestGraph[# + 1 &, 1, 10, GraphLayout -> "DiscreteSpiralEmbedding", VertexShapeFunction -> "Name", VertexSize -> .2] But ...
2
votes
1answer
69 views

Some strange graph from “RelationshipGraph”

I want use this code to graph the all of function in image-processing. ...
4
votes
1answer
27 views

How to get the VertexWeight list or EdgeCapacity list in a graph

The graph of Mathematica.We have VertexList or EdgeList.So we can get it convenient like ...
3
votes
1answer
69 views

How to make the graph to specific layout

For the artistic,the graph layout could be more important sometimes.So I must to put a bad sentence to describe the clumsy GraphLayout of ...
19
votes
2answers
377 views

Reconstruct a graph from an image (curved edges and edge crossings)

Actually, I posted a very similar question before this.How to generate a Graph from a picture of a graph Dr. belisarius's answer have answered that question, but I find a limitation in that method: ...
4
votes
1answer
75 views

Odd behaviors of FindKPlex

Bug introduced in 9.0 and persisting through 10.4 FindKPlex is new in 9.0. I have a example about it. ...
2
votes
2answers
633 views
11
votes
2answers
770 views

Convert Graph to Graphics

In Mathematica 9, a graph is returned as an object with head Graph: In[1]:= CompleteGraph[8] // Head Out[1]= Graph ...
0
votes
2answers
80 views

How to make a graph form imported spreadsheet data [closed]

I've three csv files: v.csv for vertex data, like this: 1 2 3 ... e.csv for edges: 1,2 2,4 2,24 3,1 ... and vcoor.csv for vertex coordinates: 23.4, 35.2 23.4, 40.3 ... I know how to construct a ...
11
votes
5answers
4k 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}, ...
3
votes
3answers
94 views

Random bipartite graphs?

RandomGraph[{n,m}] generates a random graph with $n$ vertices and $m$ edges. I want to generate a random bipartite graph, like ...
7
votes
3answers
326 views

Test if directed graph is connected

Is there a simple built-in way to check if a directed graph is connected? Now, before you throw ConnectedGraphQ or ...
8
votes
3answers
245 views

How to count all cliques (not just maximal ones) in graphs?

How can I count the numbers of $r$-cliques in a graph? In other words, the number of triangles, the number of $K_4$, the number of $K_5$ etc. I have tried for example ...
2
votes
1answer
66 views

VertexLabels with Graph Properties

Suppose I have a graph like this Graph[ {1 <-> 2, 2 <-> 3, Labeled[3 <-> 1, "hello"]}, VertexLabels -> Placed["Name",StatusArea] ] Now ...
3
votes
3answers
313 views
3
votes
1answer
380 views

How to convert a sparse array to a graph?

s = Import["hello.mat"]; t = GraphEmbedding[Graph[s[[1]]], "GridEmbedding"]; I get the following error: GraphEmbedding::graph: A graph object is expected ...
0
votes
1answer
63 views

How can I code a graph visibility criterion using an If-statement?

The visibility criterion can be defined as follows: two arbitrary data values $(ta , ya)$ and $(tb , yb)$ are visible to each other if any other data $(tc, yc)$ placed between them fulfills the ...
14
votes
1answer
146 views

Question about TransitiveReductionGraph

Bug introduced in 10.0 and persisting through 10.4 Note: TransitiveReductionGraph is new in 10.0. In Mathematica 10.0 and 10.1, according to the documentation ...
10
votes
1answer
89 views

Arrows from GraphicsComplex not converted to Normal form correctly

Bug introduced in 7.0 or earlier and persisting through 10.4.0 Show @ Graph[{1 -> 2, 2 -> 3}, Frame -> True] Normal @ % Is this a pure bug, or have ...
14
votes
1answer
158 views

IsomorphicGraphQ fails to recognize that two empty graphs are identical

Bug introduced in 9.0.1 or earlier and persisting through 10.4.0 Consider the following two graphs: ...
8
votes
0answers
111 views

Deleting zero edges from a graph causes bizarre behavior

Bug introduced in 10.3.0 and fixed in 10.4. Consider the following (very simple) graph, with two vertices and one edge: g = Graph[{1, 2}, {1 <-> 2}]; ...
2
votes
1answer
40 views

Certainty of the New Vertex Name after using EdgeContract

It appears that when I use EdgeContract on an undirected graph, the vertex that is the result of contracting an edge is always named the smaller of the two ...
4
votes
2answers
189 views

Ploting a parallel graph for an animation

I am sorry that my attempt to obtain a fully functional plot as I want failed badly because I am not able to integrate the features to the graph. Here is my simple code: ...
3
votes
1answer
18 views

Why does Mathematica report the VertexEccentricity of a disconnected vertex as zero?

"For a disconnected graph, all vertices are defined to have infinite eccentricity" So, why does Mathematica report the VertexEccentricity of a disconnected vertex as 0 instead of ...
1
vote
1answer
23 views

VertexContract, VertexReplace and non-anonymous collapsed node

Can the standard VertexContract or VertexReplace functions display a name for the collapsed node ? Here is a minimal example: ...
2
votes
1answer
54 views

Trying to remove duplicate isomorphic graphs in a list of graphs [duplicate]

I am working on a Mathematica program that involves taking a graph and generating all of its single-edge contractions. When I get this list of contractions, it often happens that many of the graphs ...
3
votes
1answer
65 views

How can I get the arguments of the function Graph?

If I have f0 = f[x,y,z] and I am interested in the list of the arguments, what I do is ...
8
votes
1answer
144 views

Petrie polygon projection of a hypercube graph

I am trying to generate the Petrie polygon projection of the 8-cube in Mathematica, like this one: I tried using, for example, the HypercubeGraph function: ...
11
votes
2answers
248 views

Vertex descendants subgraph

Keywords: vertex, ancestors, descendants, subgraph, directed graph, flow subtree So let's say we have a TreeGraph: ...
0
votes
0answers
14 views

Acyclic Directed Graph, NeighborhoodGraph and ancestors [duplicate]

What is the correct way of find the list of a given vertex' ancestors in an ADG ? I am thinking that a pattern in NeighborhoodGraph might be the solution or a negative option for the degree of ...
4
votes
1answer
281 views

Graphs in 3 dimensions

I have a desired graph as here: the dashed line is just for perspective representation. I tried with LayeredGraphPlot and ...
3
votes
1answer
64 views

Find independent vertex sets

I'm trying to find all independent vertex sets for a given graph. Note that they may not be maximal independent sets. There is a function in Mathematica called ...
8
votes
2answers
238 views

Plot a 3-cycle graph with clockwise-directed edges

When I try to plot a 3-cycle, the edge direction is always counter-clockwise. The plotting code is ...
6
votes
2answers
112 views

Small World network on a square grid

My aim is to generate a 2D Small World network on a square grid. i.e. 20x20. With a probability of 5%, one node rewires from an adjacent node to a random node of the grid, allowing some long distance ...