Stack Exchange Network

Stack Exchange network consists of 175 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
41 views

Coloring edges by weight and changing color but keeping shape for CommunityGraphPlot using PlotTheme->“Marketing”

(Apologies, but I cannot share the data that I am using for these graphs.) I am finding communities in my data set by using CommunityGraphPlot, and the results looks pretty good: ...
1
vote
1answer
47 views

How can I have two neural network layers act as the input to one layer?

When using NetGraph[], I am try to specify the connections between 3 layers like so: NetGraph[{...some layers...},{...{2,3}->4}] But I receive the following ...
5
votes
2answers
190 views
18
votes
1answer
760 views

How can I use the Python library networkx from Mathematica?

Is there an easy way to access the Python library networkx from Mathematica? The improvements to ExternalEvaluate in Mathematica 12.0 should make this feasible.
0
votes
1answer
34 views

Creating a directed random graph with negative assortativity [closed]

How could I create a random graph that will have a negative assortativity? A graph where nodes with small degree will tend to connect to nodes with a high degree and vice-versa. Any ideas are much ...
9
votes
2answers
203 views

Finding the path in a graph from A to B then back to A with a minimum of shared edges

the problem is to find cycle from A to B back to A, so that the path B-A would use minimum edges from path A-B. The graph is undirected and can have cycles. The paths don't have to be shortest, they ...
1
vote
1answer
43 views

Obtaining the vertex cosine similarity from a graph

Given a set of edges, how can the adjacency matrix of these edges be populated with each vertex pair's cosine similarity measure? Consider this edge set: edges = {TX -> R1, R1 -> R3, R3 -> R5, R5 ->...
4
votes
1answer
120 views

Currents/voltages graph for an electrical circuit

I am trying to design the network graph for an electrical circuit. I have done this by hand so far. Here is the code for the voltages graph ...
4
votes
1answer
59 views

I want to place the edges of a Hamiltonian cycle

I don't understand why, but the GraphLayout style "CircularEmbedding" doesn't place the vertices/edges of a Hamiltonian cycle on the circle. Is there any way I can ...
3
votes
0answers
48 views

IncidentGraph not showing edge weights correctly

I am performing the following commands: ...
4
votes
1answer
140 views
5
votes
3answers
150 views

Ideas for colorfully and clearly highlighting graph edges according to weights

I am trying to figure out a way to include edgeweights in the visualisation of a graph in Mathematica, to find an idea for the drawing such that even for relatively large node numbers the graphs ...
2
votes
2answers
66 views

Generating a constrained directed graph from an adjacency matrix

I have written the following Code ...
5
votes
5answers
426 views

Neighboring nodes in the network

Consider the graph: ...
4
votes
1answer
76 views

The road in the graph

Consider the graph: ...
6
votes
1answer
63 views

IGraph/M Library - ConfigurationModel

I am trying to reproduce a network generated by a configuration model given degree vector truncated power law distribution. I am relying on the following function from the IGraph/M package for ...
2
votes
1answer
40 views

Draw complete graph with vertices placed at random positions? [closed]

How can I draw a complete graph on $N$ vertices, such that the vertices are placed randomly on the plane?
12
votes
1answer
120 views

Why is IsomorphicGraphQ so very slow (in this instance)

Can someone explain why the following code does not complete within a reasonable time? ...
4
votes
1answer
60 views

Boxed option does not work with Graph3D

Bug introduced in 10.0 or earlier and fixed in 12.0 Boxed is an Option for Graph3D, however ...
4
votes
2answers
82 views

How to construct the graph of nearest neighbor diagonal squares on a chessboard from BishopGraph

I have already found a way to generate this graph with the following: ...
12
votes
2answers
782 views

Solving “Resistance between two nodes on a grid” problem in Mathematica

In the context of resistor networks and finding the (equivalent) resistance between two arbitrary nodes, I am trying to learn how to write a generic approach in Mathematica, generic as in an approach ...
0
votes
0answers
48 views

LayeredGraphPlot with Tooltip

In the Tooltip I want to change LinkHand for an image of a medium sized clock, but I get an error. In the following image I ...
5
votes
2answers
229 views

Finding the dangling free part of a cluster connecting two nodes

I am trying to learn how to use Mathematica for analyzing graphs, more specifically in the context of connectivity and percolation. For the sample graph that I have included in this post, we have a ...
16
votes
1answer
935 views

How to visualize a Cayley graph in this style?

I'm trying to create a similar style of image like this one, which is the Cayley graph of $A_{5}$. With Mathematica, I just can create the following ...
8
votes
0answers
98 views

StableMarriage vs. FindIndependendEdgeSet: How to use the procedure FindIndependendEdgeSet as a Gale-Shapley algorithm?

From Help, the procedure StableMarriage was an element of the Combinatorica, but it is available in the built-in ...
0
votes
0answers
36 views

All shortest paths from start vertex s to end vertex t for graphs with positive edge weights [duplicate]

The code for finding all shortest paths from start vertex s to end vertex t is provided in BreadthFirstScan. The relevant parts are under Applications, then ...
2
votes
1answer
58 views

Place table inside a graph

I have a simple graph: mygraph = Graph[{1 -> 2, 2 -> 3, 3 -> 1}] and a simple table: ...
3
votes
1answer
70 views

Automated calculation of tree branches radius from thinned image

I am progressing in the branching problem described here. After having extracted my tree structure and done a lot of manipulations on it (very interesting, but not described here), I would like to ...
1
vote
1answer
48 views

All shortest paths code: PropertyValue error $Failed (Edited to narrow and with added code example that does run fine on a different graph)

I am working on the following code (to generate all shortest paths in a graph) It executes fine until the last two lines. PropertyValue[{g, t}, "ShortestPaths"] gives $Failed Is there an issue ...
4
votes
1answer
48 views

Associate vertex coordinates and labels

This sounds easy (in which case I will delete my question) and maybe I am getting a bit tired, but I can't find an easy way to create a list from an automatically-generated graph where vertices labels ...
1
vote
0answers
36 views

How to get a directed graph of size N which is also a connected component?

I need to get graphs of size N, in which the whole graph is a connected component. In particular, I'm working with a Albert-Barabasi distribution, with k=2, and random directed edges. Right now I'm ...
1
vote
1answer
73 views

Reap and sow for BreadthFirstSearch

The following Code highlights the breadth-first scan tree ...
3
votes
3answers
135 views

Displaying two items in a graph's edge labels

Is it possible to have double edge labels displayed by a graph? I tried EdgeLabels -> {Placed["Index", 0.5], Placed["Name", 0.25]} but it didn't work.
0
votes
0answers
15 views

Directed graph, immediate predecessor of a vertex [duplicate]

In a directed graph, how do you determine all incoming neighbors of a vertex? For the graph {1 -> 2, 0 -> 2, 2 ->3} the incoming neighbors of 2 should 1 and 0. I checked out AdjacencyList. This works ...
5
votes
2answers
65 views

Counting the number of unconnected subgraphs

If I have a Graph, how can I count how many disconnected pieces it has? Mathematica must know this since it is able to separate them out when it displays the graph, ...
8
votes
2answers
369 views

Branching points detection in processed image

I want to get the branching coordinates from a computer-generated image like this one: After SkeletonTransform and Pruning, I ...
1
vote
0answers
39 views

CommunityGraphPlot of weighted graph: node too far

I am playing with weighted Graph and CommunityGraphPlot, and I am considering the following example. ...
1
vote
2answers
42 views

Infix notation for VertexLabels in a Graph (reformulated from a closed topic)

I am reformulating this question as it was incomplete. I want to label vertices in a graph with expressions in infix notation. I copy my code below. First part converts a list of expressions to ...
4
votes
1answer
65 views

Plotting a graph with its vertices on a circle

If have the following code. AdjacencyGraph[Table[Boole[CoprimeQ[i - j, 8]], {j, 0, 7}, {i, 0, 7}]] This generates a graph with 8 vertices. If the vertices are ...
3
votes
0answers
77 views

Hopcroft's Algorithm for Minimization of Deterministic Finite State Automaton

Background Given a deterministic finite state automaton, Hopcroft's algorithm is a $O(n \log(n))$ algorithm for finding an automaton that generates the same language with a minimal number of vertices....
5
votes
2answers
147 views

Separating disjoint sub-Graphs

Background: I am comparing the financial data from some 60 hospitals in The Netherlands over 2012 - 2017. The data are public, but need to be curated manually, as e.g. some hospitals have merged, some ...
2
votes
1answer
54 views

What is substitute for HighlightCentrality? [closed]

I have a graph that has determined the Betweenness Centrality value for each vertex. I want to visualize the difference in the centrality value on the graph. Based on the documentation we can do it ...
7
votes
1answer
354 views

Graph-like info-graphics

The Sunday, January 27, 2019 New York Times has a superb info-graphic describing the path from citizen to Member of the House of Representatives for the current members, including steps such as ...
1
vote
0answers
18 views

what replaces MinimumVertexColoring? [duplicate]

It is straightforward to find the chromatic number of a named graph in Mathematica's database of graphs. What is the simplest way to find a coloring of the vertices corresponding to the chromatic ...
1
vote
0answers
41 views

Labeling edges in Graph

I want to make a graph of the mother nuclides of all Tin Isotopes. I found this ...
9
votes
6answers
427 views

Finding the largest rectangular submatrix

I have a sparse non-symmetric binary matrix with a block structure. The dimensions of the matrix are thousands rows and less than one hundred columns. How do I identify the largest non-contiguous ...
1
vote
1answer
39 views

Converting Graph3D to Graphics3D

How you do convert a Graph3D (or GraphPlot3D) into Graphics3D? Graphics3D@ButterflyGraph[3] ...
4
votes
4answers
81 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: ...
3
votes
1answer
49 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
63 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 ...