Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

1
vote
1answer
29 views

Derivation of flow equations in a digraph

I have a digraph called weightedG and like to derive some relations between flows. ...
6
votes
2answers
61 views

GraphDistance error when Graph vertices are Associations

Bug introduced in 10.0 or earlier and persisting through 11.3 Here is a nice graph whose vertices are Associations: ...
2
votes
1answer
55 views

Relocation of vertices in a digraph, using Euclidian distance measure

My objective is to produce a Mathematica code to calculate a[j] for every vertex j. I have ...
4
votes
1answer
77 views

Completing graph edges “around the world” to GeoPlot an itinerary

My central goal is to plot a complex international inter-city itinerary on a world map, which might include repetitions of a single segment (e.g., New York to London or London to New York). The ...
7
votes
1answer
88 views

Relative Neighbourhood Graph

Is there some way to efficiently compute the relative neighbourhood graph on $n$ Euclidean points in $\mathbb{R}^{d}$? Though one can simply define ...
3
votes
1answer
107 views

Formulating a tailor-made Maximum Flow problem in a directed graph

Let a digraph, G, be given, where t[i,j] and a[j,i], respectively, denote transfer capacity ...
1
vote
1answer
30 views

Symbolic identification of all the pathways from vertex s to vertex t in a directed graph

Suppose that we have a symbolic digraph, meaning that, except the vertex names, edges in the digraph G are all String. ...
1
vote
0answers
30 views

Finding all the pathways from vertex s to vertex t

Suppose that we have a complete graph with n=5 vertices: vertexset={1,2,3,4,5} We want to identify the set of all the paths (...
3
votes
2answers
74 views

Label Product of a Graph with itself

Defn Let $\mathcal{G}=(\mathcal{V},\mathcal{E})$ and $\mathcal{G}' = (\mathcal{V}', \mathcal{E}')$ be two labeled graphs with alphabet $\mathcal{A}$. The labeled graph product $\mathcal{G} * \mathcal{...
2
votes
0answers
31 views

Increase vertex embedding distances e.g. scale VertexCoordinates

I currently try to make following graph more readable: ...
1
vote
1answer
34 views

Inconsistent edge label positions in a graph with straight and curved edges

Consider this small graph with a straight edge between two nodes and another edge being a loop at one of the two vertices: ...
7
votes
2answers
161 views

Weighted graph with multiple different coloured non-weighted paths - styling

This follows on from my previous question answered here. Ultimately, I now have a graph which I've simplified for posting here: ...
2
votes
1answer
49 views

Adding overlapping non-weighted, directed edges to a weighted, undirected graph

I have the following Mathematica code based on the GDB1 instance from the CARP literature: ...
0
votes
0answers
35 views

CommunityGraphPlot is not plotting in my Manipulate expression

I have two directed graphs $g1$ and $g2$. The following community detection code works fine for $g1$. ...
3
votes
1answer
75 views

Layered Graph Drawing: Specify Layer for Nodes

I was trying to recreate following graphviz graph with Mathematica 11.2: ...
1
vote
0answers
20 views

How might I make the vertex labels in a tree plot clickable, the click triggering the playing of a sound?

This project explores epimoric ratios in relationship to musical harmonics. I have a simple treeplot of epimoric ratios in their relationship to each other. I generate it thusly: ...
1
vote
0answers
67 views

Maximum Flow in a directed graph of a system of nonlinear ordinary differential equations

Let $G=(V,E)$ be a directed graph with $n$ vertices, $V$, and a set of $m$ edges, $E$. Each edge is a function of two unknown parameters, $[t(i,j),a(i,j)]$ and a given value for $x(i)$. If the two ...
4
votes
2answers
112 views

How to generate random Directed Connected (Planar) graphs?

I need to create all possible connected and directed graphs with N vertices. The graphs are Planar and labelled with vertices 1 to N. Although the graphs are unweighted, the graphs are non simple ...
7
votes
2answers
162 views

Bug in NearestNeighborGraph

NearestNeighborGraph generates incorrect output on rasterized input. Reported to Wolfram support CASE:4093797 $Version 11.3.0 ...
4
votes
3answers
113 views

Spectrum of the GraphData

I'm new in using Mathematica. I need to generate graph spectrums for line graphs of all graphs with vertices number smaller than 5. I used this command to generate all LineGraps: ...
4
votes
1answer
61 views

Problem in coloring network links with linear gradients through VertexColors

I am trying to plot a network with colored links and nodes. I would like to color links with a gradient depending on the colors of its endpoints/nodes. For instance, a link between a blue and a red ...
5
votes
0answers
72 views

Generating random mixed multigraph with random edge weights

The following function generates a random mixed unweighted multigraph: ...
3
votes
1answer
241 views

How to calculate all possible resistances made from 5 distinct resistors in series and/or parallel? [closed]

Five distinct resistors resistors={1,2,3,4,5} are given. The objective is to find a list of all possible resistances obtained by configuring all these resistors in ...
4
votes
0answers
35 views

Weird behaviour when importing a mixed graph from GraphML file

Consider a mixed graph G1 stored in GraphML file: ...
0
votes
0answers
41 views

How does Mathematica define an equality ( == ) for Graphs?

I am confused. For instance ...
0
votes
0answers
20 views

Positioning of vertex labels on graph [duplicate]

How can I position the vertex labels outside of the "circle" in CircularEmbedding? For example executing the code snippet ...
12
votes
1answer
153 views

Exporting graph object for later use

We are planning to analyze geometry of artery branch pattern. We convert the binarized image into graph object using MorphologicalGraph[]. To avoid the complexity ...
1
vote
1answer
24 views

Node label's letter case in graph incorrectly displayed [closed]

Upon constructing the following graph, I expected the node labels to appear as per what is provided. The letter case of Node E is not in CAPS as shown below. Please correct me if I misunderstood ...
1
vote
1answer
75 views

Toroidal metric in a random geometric graph

I have some code I've been using to generate some random geometric graphs as fast as possible. The boundary conditions on the rectangular domain I am using sometimes interferes with a clean ...
5
votes
1answer
42 views

How to maintain graph style in HighlightImage?

Highlighting an image with a graph seems to change the styles of the graph vertices: ...
5
votes
1answer
78 views

Undocumented GraphComputation`GraphProduct usage

According to Mathworld there is an undocumented function GraphComputation`GraphProduct[G1, G2, "Cartesian"] To compute the cartesian graph product. Now in ...
4
votes
0answers
152 views

Loopy Belief Propagation

I look for an efficient way to implement a Belief Propagation in Pairwise Markov Random Field. Each node is a binary random variable, and the unary potential function is ...
2
votes
1answer
54 views

Strahler order of a graph(drainage network)

How can I find the Strahler order of a drainage network in Mathematica? For example the link created by joining links of order $i$ and $j$ is given by $k=max(i,j,Int\frac{1}{2}(i+j))$. The image of ...
1
vote
1answer
33 views

How does the FindShortestPath function handle situations with multiple paths and how does this affect the BetweennessCentrality function?

I'm using the FindShortestPath function and am curious to know how Mathematica determines the shortest path when multiple such paths exist. Here's what I have: <...
1
vote
1answer
53 views

Multiple compiled functions modifying having access to and modifying global variables

I would like to implement the following algorithm for finding strongly connected components in Mathematica: I would prefer to keep the structure of the pseudo-algorithm, and would like each of the ...
3
votes
2answers
136 views

How to extract graph from microscope image?

I have a microscope image of actin filaments and I'd like to extract the geometry of the bright lines into a Graph object: Here's what I have so far, using the ...
1
vote
0answers
18 views

Optimal Size labelling for saving Graph on File

I looked at Labeling vertices by number in Graph: Getting text to display at the right size but did not find an answer for my case. I want to save a table of graphs on file, pdf or PNG, for a ...
2
votes
1answer
52 views

Index of MorphologicalGraph[] and GraphEmbedding[] do not match

I am planning to automatically detect number of bifurcation of each node in tree structure from images. At first we obtain tree graph from image using ...
4
votes
2answers
118 views

Finding patterns in Graph visualization

Please comment me if you think this question is not related to Mathematica stack exchange. I am trying to draw a graph representation of the system shown below As you can see, when red line passes ...
3
votes
2answers
143 views

weighted graph from the sparse matrix

I interested to create a weighted graph from the sparse matrix of weights. The following code works for small examples, but to the graph, with few thousands of node, it does not work. ...
3
votes
2answers
76 views

How to filter-out edges in a HighlightGraph[] visualization based on VertexCoordinates[]?

I need to visualize a graph spatially, and I'm simply using: HighlightGraph[ConnectedGraphComponents[]] and the known coordinates of the graph's nodes. I really ...
7
votes
4answers
264 views

How to remove “extra” edges from a multigraph?

I programmatically generate many large undirected graphs. Sometimes these graphs are multigraphs, that is, they contain more than one edge between a pair of nodes. I've tried to delete the "extra" ...
1
vote
1answer
65 views

Tree Graph for bronchial structure from morphometric data

I have read other questions related to TreeGraph but couldn't find something similar to my problem. I have a list of geometric properties of the bronchial tree, where each bronchus is represented by ...
1
vote
1answer
46 views

How to draw a graph with background in dark, and vertexes in light?

I have a graph gph as below: gph = Graph[{1 -> 2, 2 -> 3, 3 -> 1}] Currently, the background is white, and the ...
0
votes
1answer
52 views

Graph (network) styling: avoid vertices and edges overlapping

Is there a way to avoid the edges and vertices 'overlapping' in a graph with custom styling? That is, the edges should stop once they reach the 'border' of the shape representing the vertex (in this ...
3
votes
1answer
75 views

Sampling “Random” Cyclic / Acyclic Graphs

This is an extension of RandomGraph with specific constraints Where @Histograms wanted to make $n$ random graphs with a specific constraint (in @Histogram's case, having 2 vertices each with exactly ...
1
vote
1answer
43 views

Exclude the radial lines in a graph

Suppose I have a graph formed by the edges {4 <-> 1, 1 <-> 3, 3 <-> 4, 1 <-> 3, 1 <-> 5}. Then I define my own line numbers to those ...
3
votes
1answer
85 views

Performing queries on mesh structure in a clean way

I have the following problem, which can be stated geometrically as follows: List all pairs of vertex coordinates in a mesh region of measure 2 (a surface consisting of triangles) where these points ...
2
votes
3answers
73 views

Find parallel line numbers in a graph

Suppose I have a graph formed by 3 vertices and 4 lines. {4 <-> 1, 1 <-> 3, 3 <-> 4, 1 <-> 3} Let the line numbers be ...
5
votes
4answers
104 views

How to align array plot and graph plot?

I would like to combine a MatrixPlot and a GraphPlot, but I can't find a way to align them. The code is ...