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 tagged [graphs-and-networks]

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

1
vote
1answer
33 views

How to find efficiently the independent vertex sets from a large adjacency matrix?

I have a binary adjacency matrix $M$ of size $72\times 72$. I would like to find all possible combinations of 18 non-adjacent nodes. There are $^{72}C_{18}$ possible (adjacent and non-adjacenct) ...
6
votes
2answers
296 views

How to color nodes in a adjacency graph with different colors?

Let us consider a binary adjacency matrix $M$. We want to color the nodes of corresponding adjacency graph with 4 different colors such that two adjacent nodes have different colors. How to find 4 ...
15
votes
1answer
395 views

Generating and rendering extremely large graphs

I'm interested in generating and rendering extremely large graphs, i.e., ones having $10^6 \to 10^8$ vertices. (These graphs will ultimately be rendered in PDF or PNG and printed on large, poster-...
3
votes
3answers
83 views

Why Graph does not recognize chains of vertexes like NetGraph

Cross posted on Wolfram Community. Perfect logic: NetGraph[{1, 1, 1}, {1 -> 2 -> 3}] But this does not make sense: ...
27
votes
5answers
1k views

Elegant implementation of factorial tree graph

Consider the tree graph used in part of my solution to this question: Each level $i$ has $i!$ nodes, and the branching ratio is $i+1$: I kludged together code to generate this graph (with code ...
3
votes
1answer
54 views

How to change node color in .dot file using pattern matching?

For example I have a dot file that describe a decision tree or binary tree In the file, the color of node is always gold, so I try to change it according the number in ...
0
votes
0answers
29 views

Recursive function call in Fold: $RecursionLimit issue

I'm trying to generate a list of all local complements of a graph $G$. A local graph complement $G\star v$ for $v\in V$ is defined as taking the neighbourhood of the vertex $v$, and flipping the ...
4
votes
1answer
53 views

Automatically avoid overlapping labels and edges?

How can I automatically avoid vertex labels overlapping with edges? ...
0
votes
1answer
21 views

Cut graph at a given edge and return remaining subgraphs?

I would like to have a function that removes an edge from a graph and returns all remaining graphs after the operation. For example for a graph like ...
1
vote
0answers
24 views

How to form sets of non-adjacent subgraphs from all possible subgraphs and the adjacency matrix?

I have connected graph with $72$ nodes. The binary adjacency matrix of the connected graph is $A$. The size of $A$ is $72\times 72$ and its symmetric. I have generated all possible subgraphs ($17000$...
0
votes
1answer
138 views

How to form subgraphs from a connected graph

I have a connected graph with 72 nodes and its binary adjacency matrix. I need to find all possible connected subgraphs with exactly 6 nodes, i.e., I need to find all connected subgraphs and each ...
6
votes
4answers
336 views

Iteratively strip off simply connected edges in graph?

Consider a set of edges composing a directed graph. For example: ...
2
votes
1answer
59 views

How do you find a sub-graph and replace it with another subgraph?

I saw a video where SW shows how he has a large graph and some rules for finding a given subgraph in a graph and replacing it with another subgraph. How would one go about doing this in Mathematica? ...
0
votes
1answer
48 views

Getting a Dodecahedron Graph to work in Manipulate [closed]

Right now I am currently using a grid graph for a "shortest path model", but ideally, I would like the shortest path model to work on a pentakis dodecahedron or rhombic triacontahedron. I will say I ...
6
votes
1answer
55 views

Loading IGraphM on a Remote Cluster

I am trying to load IGraphM on a remote cluster at a university. I can load the program, then install the package, which is successful I then run <<IGraphM, ...
6
votes
2answers
86 views

How to add arbitrary node/edge attributes for export as Graphml file?

I would like to add arbitrary attributes to a graph G that I can access in other software, after exporting as a graphml file. If I export ...
4
votes
2answers
267 views

Generating a lattice graph

How can I generate the following lattice graph? You are welcome to make your own assumptions. Is it possible to this using GridGraph?
17
votes
2answers
352 views

How to build a neighbor table for the Hexagonal lattice

I want to consider a collection of vertices arranged in a finite Hexagonal lattice, with say $n_{r}$ rows and $n_{x}$ vertices per row, for a total of $N = n_{x}n_{r}$ vertices. The goal is to ...
1
vote
3answers
93 views

Find k largest edges with unique nodes (kind of maximum weighted matching)

I have a weighted graph, and I am interested to find k largest edges with unique nodes. Currently, I do it in the following manner ...
4
votes
1answer
35 views

Force GraphLayout to put specific node at top

I've got a tree graph and I would like to have a specific node be the root in the laid-out Graph as well. Here's a MWE: ...
1
vote
1answer
61 views

Coloring multi-edges in graphs

I have the following edgelist and colors: ...
5
votes
2answers
118 views

GraphUnion but with multiple edges?

I have two graphs G1 and G2 with the same vertex set. I would like to take the union of G1 ...
1
vote
1answer
32 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
74 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
58 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
88 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 ...
8
votes
2answers
138 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
2answers
140 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
31 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
31 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
78 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
51 views

Increase vertex embedding distances e.g. scale VertexCoordinates

I currently try to make following graph more readable: ...
1
vote
1answer
36 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
166 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
54 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
41 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
88 views

Layered Graph Drawing: Specify Layer for Nodes

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

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

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
76 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
129 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
163 views

Bug in NearestNeighborGraph

NearestNeighborGraph generates incorrect output on rasterized input. Reported to Wolfram support CASE:4093797 $Version 11.3.0 ...
4
votes
3answers
120 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
64 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
75 views

Generating random mixed multigraph with random edge weights

The following function generates a random mixed unweighted multigraph: ...
3
votes
1answer
250 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
39 views

Weird behaviour when importing a mixed graph from GraphML file

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

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

I am confused. For instance ...
0
votes
0answers
22 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
156 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
26 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 ...