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
28 views

Converting Graph3D to Graphics3D

How you do convert a Graph3D (or GraphPlot3D) into Graphics3D? Graphics3D@ButterflyGraph[3] ...
0
votes
0answers
34 views

Is there a function that implements Vehicle Routing problem in Mathematica [on hold]

For my assigment, I need to present ways to solve Vehicle Routing problem in Mathematica, but I can't find any built-in function that does this. Is there any way to do this in Mathematica?
4
votes
4answers
65 views

Get complete graph from set of vertices?

There is a function in Mathematica called CompleteGraph which takes a number and makes a complete graph with that number of vertices: ...
2
votes
1answer
22 views

Specify input ports with NetGraph for network within a network

I have a network with two input ports ("a" and "b"). I want to use this net within a bigger network. The problem is that I cannot find a syntax to specify to which input port the previous layers of ...
4
votes
1answer
56 views

Using TeXForms as vertices of a Graph

I have a set of equations written in TeX that I want to use as vertices of a graph, with edge labels showing how the equations are connected. I read the equations in from a file, then replace any ...
4
votes
1answer
41 views

Mathematica package to calculate the graph crossing number

I have been searching for a mathematica package that can calculate the graph Crossing number of a (small) given arbitrary graph (the graphdata of known graphs doesn't help me). Before I write my own ...
3
votes
1answer
65 views

Trim graph to fully connected components?

Given a graph like e.g., ...
1
vote
0answers
68 views

How can we make an algorithm with the A* method in Mathematica with 5 different flight routes? [duplicate]

I need to find the shortest path with the A* algorithm using Mathematica. I have 5 different flight routes with coordinates. They start and end at the same point. Between every point there is a wind ...
20
votes
3answers
931 views

How can I make a graph network from image of granular packing?

I have an image from experimental data of granular packing. I need to characterize the packing as a network. The network consist of node (center of granular particle) and edge. Two node are connected ...
3
votes
1answer
60 views

Customising GraphPlot

I am trying to get GraphPlot to order the nodes always in the same way. Unfortunately the graph spec (set of rules defining the connectivity) seems to override the <...
1
vote
0answers
51 views

Decay chain browser

This https://demonstrations.wolfram.com/IsotopeBrowser/ used to be an excellent tool to demonstrate decay chains to my students. Unfortunately it does not work under newer versions of mma. Can anybody ...
4
votes
1answer
63 views

Highlight all paths in a graph below some threshold length

I have a weighted graph, for example, a random geometric graph within a square domain $[-1/2,1/2]^2$, with a node fixed at the origin. How do I use HighlightGraph to show all there paths which start ...
2
votes
1answer
31 views

Version 9 - delete edge from Delaunay Graph

I have a problem with subgraph in Mathematica 9. In Ver10 the below code works : ...
2
votes
3answers
67 views

How can I compute the chromatic number of a graph?

I'm starting in Wolfram Mathematica. I saw that MinimumVertexColoring [g] could be used to calculate the chromatic number of a graph, but ...
5
votes
1answer
81 views

Why Does GraphPlot mislabel Vertices from a Graph?

A very peculiar thing is happening when I wrap a Graph with GraphPlot. The picture below shows the correct vertex labeling. However, GraphPlot changes the vertex labeling! Am I misusing this function ...
2
votes
2answers
34 views

Extract EdgeList From Non-Square Matrix

Given a non-square 3x10 matrix like below, is there a way to extract the implied EdgeList from it. For example, the Edgelist from the below matrix would be S1->F1, S1->F5,S1->F9, S2->F9,S3->F1,S3->F9 ...
9
votes
4answers
535 views

How to remove vertices from a graph?

I have 2 lists: list 1 is a list of vertices of a graph, says, {1,2,3,4,5} and list 2 keeps track of edges (i.e which vertex connects to which) such as {{1,2}, {2,3},{3,4},{4,1},{2,5}}. Now I want to ...
9
votes
1answer
234 views

How to color each edge of a graph with two colors?

This is a chord visualization taken from here. The corresponding code for visualization is ...
0
votes
0answers
33 views

How to form clusters from adjacency matrix and node weights?

Let us consider a binary adjacency matrix $M$. Lets us also consider that each node has a weight. I want to form clusters (with given cluster size, for example, 6 nodes in each cluster) where the ...
0
votes
2answers
51 views

Problem with FindShortestTour function

I'm new to Mathematica but I've read some documentation and guides and, unfortunately, haven't found a solution. There's the following matrix in the task: And I have to solve this TSP problem ...
1
vote
1answer
40 views

Calculation of non-overlapping set (ordering set ) of minimum spanning trees

I am interested in calculating a set of non-overlapping minimum spanning trees of a weighted graph. For example to calculate the set of size 3. I calculate the maximum spanning tree, remove its edges ...
0
votes
1answer
43 views

Program to delete node/vertex from graph having out degree zero

Program to delete a node from graph having out degree zero. Consider the following graph where M -no. of edge, N-no. of vertices, (u,v) edge. M=6, N=6 1 2 1 3 1 6 2 3 3 4 3 5. I want to delete 6, 5 &...
1
vote
1answer
128 views

How to derive the graph of any n-step transitions through a Markov chain

Context: The code below produces the graph of a Markov chain with the transition probabilities shown on each edge. If I chose any vertex to start from, say vertex 1, I would then like the graph of all ...
1
vote
1answer
40 views

Graph: absolute vertex size

How can I set absolute vertex sizes in Graph, so that the vertex size on screen (number of pixels or printer's points) is invariant to changes in the option ...
1
vote
1answer
38 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) ...
7
votes
2answers
318 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 ...
20
votes
1answer
532 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
90 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: ...
29
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
60 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
30 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 ...
5
votes
1answer
75 views

Automatically avoid overlapping labels and edges?

How can I automatically avoid vertex labels overlapping with edges? ...
0
votes
1answer
24 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
27 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$...
1
vote
1answer
144 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
340 views

Iteratively strip off simply connected edges in graph?

Consider a set of edges composing a directed graph. For example: ...
2
votes
1answer
70 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
53 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
58 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
97 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
276 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
404 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
95 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
36 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
68 views

Coloring multi-edges in graphs

I have the following edgelist and colors: ...
5
votes
2answers
121 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
34 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
76 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
60 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
94 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 ...