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.

Filter by
Sorted by
Tagged with
0
votes
2answers
25 views

Edge list of a graph as a simple list of lists of pairs of integers?

Suppose I have a list of graph edges in the form: e={UndirectedEdge[1,2], UndirectedEdge[3,4]} How can I convert this to a simple list of lists: ...
10
votes
2answers
897 views

Causal Diagrams using Wolfram?

How can one use Wolfram to make diagrams like with the arrows labeled as well (to label "mediating factors" between the causal elements)?
17
votes
2answers
416 views

Creating graph out of particles images

I have recently started learning how to use Mathematica's brilliant image processing tools, and the image I've taken as first example is the following (source): So far I've tried to first use ...
3
votes
1answer
85 views

Reverse graph generation

The more usual way of generating graphs and random graphs, is to start from a mechanism of adding nodes (e.g. randomly embedding or connecting, or randomly rewiring edges, etc), and for which we know ...
10
votes
3answers
1k views

Efficiently finding furthest two nodes in a graph

I am trying to learn how in an efficient way can one find the diameter of a random graph, that is, the longest shortest path, and its corresponding end-nodes. The direct built-in function ...
5
votes
3answers
172 views

Convert graph format for Mathematica graph functions

I have an output of many large graph files, specified by pair of vertices, in a format like ...
0
votes
0answers
35 views

High dimensional integral not evaluating? [duplicate]

I am trying to integrate as follows: ...
3
votes
0answers
59 views

Steiner Tree Approximation

I am wondering about the existence of Mathematica code to find (approximate) Steiner trees in graphs. I know there are a number of algorithms to do so --- just curious if anyone has implemented any ...
3
votes
1answer
77 views

How to plot connected components in the format of community structure plot?

I have the following code plotting community structure of random graph g. As one can see, the community structure plot presents ...
5
votes
1answer
108 views

Drawing finite-state automata without using VertexRenderingFunction

In the tutorial entitled "Hierarchical Drawing of Directed Graphs" in Mathematica 12, there is an example of how to draw a graph with several properties I want, but it uses an option called ...
3
votes
1answer
74 views

Edge weights in directed graphs

Apologies for what seems like a silly question. I'm sure I am missing something obvious, but this is driving me a bit crazy. Does EdgeWeight work differently in Directed vs. Undirected graphs? If I ...
1
vote
2answers
90 views

How to position vertices according to clustering coefficient in a nice way?

I have a graph and I want to rank each vertex according to its local clustering coefficient. I have done the following: ...
6
votes
0answers
72 views

Mathematica's algorithm for FindIndependentEdgeSet? [closed]

Documentation does not mention about algorithm. My guess is Blossom algorithm because I do not know of any better one. Posting it with hope that someone might know it for sure.
2
votes
2answers
69 views

Finding Non-Simple Paths of a Given Length on a Graph

For the following graph: ...
5
votes
2answers
125 views

How to get distinct labels on parallel edges in a graph?

The following doesn't display as you'd expect: Graph[{Labeled[1 -> 2, "A"], Labeled[1 -> 2, "B"]}, VertexLabels -> "Name"] The parallel edges are both ...
6
votes
2answers
111 views

Color Specified Vertices in LayeredGraphPlot

Can vertices S and R9 (for example) be fill colored (say red or black) in a LayeredGraphPlot? ...
0
votes
0answers
37 views

Function iteration

I wrote a function in Mathematica that applies certain construction steps on the "incidence matrix" of a graph in order to obtain a new graph with certain properties. These construction steps can be ...
0
votes
1answer
51 views

Forced colorings with IGraph/M

Is it possible to force the colors of certain vertices in a graph so that the function which finds a minimum coloring will then extend the partial coloring with the fewest possible number of extra ...
2
votes
2answers
54 views

No difference between TraditionalForm and StandardForm in Graph labels

TraditionalForm seems not to be working properly on Mathematica 11.3 when used in Graph. The following MWE ...
2
votes
0answers
35 views

The function VertexContract does not work in specific case

I am using the function VertexContract and I am experiencing that it does not work in some specific cases. If I give the graph with EdgeWeights, EdgeLabels and VertexLabels, I cannot contract {2,5} ...
3
votes
1answer
74 views

Generating all connected graphs from a set of n-valent vertices?

I would like to have a function generateConnected[list_] that, given a set of vertices with pre-defined valence (number of outgoing edges) generates all possible ...
9
votes
2answers
730 views

How can I get edges to bend to avoid crossing?

I want to generate a layered drawing of the Hoffman–Singlelton graph. As an example of what I want, here is a layered drawing of the Petersen graph: Now if I right click on the output of ...
1
vote
0answers
36 views

Alternatives for chromatic number in graphs

The function IGChromaticNumber in IGraph works great, so well, that I have been able to check the chromatic number of graphs with max degree 12 with over a thousand vertices in a relatively short ...
3
votes
1answer
185 views

Graphical representation of connection of people

I want to make a graphical representation of the people with the location, but coding is a little bit challenging. Here is my input {Person,Location,Influences} ...
1
vote
3answers
76 views

Generate a graph from function on the vertices

I have a concrete function $f:V\rightarrow P(V)$ that describes the neighborhood of a vertex $g$. I tried to use FunctionalGraph[f, V] , but apparently, this ...
1
vote
0answers
49 views

How can I parametrically generate a hierarchically clustered network? [closed]

I'm trying to create an image to illustrate what a large, hierarchically clustered network looks like. The details of the network don't matter, as long as, when plotted, it clearly shows at least a ...
1
vote
2answers
50 views

Constructing multigraph from vertex list

Given a list of vertices, with each vertex containing an edge list: vertices = {{"foo","3","bar"},{"3","bar"},{"foo"}} How can I construct a multigraph where ...
9
votes
2answers
210 views

Mathematica Subgraph “Neat Example” not working properly in Mathematica 12

I have tried running the example given in the neat examples section of 'Subgraph' function in Mathematica 12.0 (windows 10) and the example does not run properly for any number of tries. The same ...
2
votes
2answers
43 views

Efficient ListConvolve over 3d matrix

I'm trying to find an efficient way of applying list convolve to a 3d matrix of 0 and 1, where about 5% of the matrix are 1, but the 1s may either be randomly placed, or grouped in one large ...
0
votes
0answers
45 views

A function for finding normal edge-5-colorings of cubic graphs

It would be nice if the following were available: Definition A normal edge-k-coloring of a cubic graph $G$ is a proper edge-$k$-coloring of the graph such that for any edge $e\in E(G)$, $e$ and the ...
0
votes
1answer
36 views

How to properly use image as vertex labels to draw graphs?

I imported an image and used it as vertex labels to draw a graph. The problem is I cannot control the size of the image. So it looks like this. Here's my code. ...
4
votes
1answer
60 views

Question about FindKClique

Say we have a graph: g = CompleteGraph[5]; and that we want to find all the triangles in g. I tried to use ...
5
votes
2answers
86 views

How to add SwatchLegend to a graph?

I created a random graph with each vertex colored randomly. I would like to add a SwatchLegend to the graph to indicate the value corresponding to a color. How can ...
4
votes
1answer
176 views

Graph flow chart

I am trying to reproduce this figure using Mathematica. I am not even sure it is possible. Maybe Graph approach can be used. Here is my starting point. ...
1
vote
0answers
32 views

Is is possible to plot a multilayer network?

I would like to generate and plot a network of networks, otherwise known as a multilayer network. That is, I have one network of type A nodes with type a links. I have another network of type B nodes ...
1
vote
3answers
71 views

Expressing an Edge List as a 0-1 Table with Headers

Consider the edges ...
2
votes
1answer
35 views

Edge coloring of multigraphs with IGraph/M

Does the current implementation of IGMinimumEdgeColoring and IGChromaticIndex in IGraph/M work with multigraphs? I recall ...
6
votes
3answers
236 views

How to supress loops in a digraph?

I have the following Code working nicely (Part of this code has been developed by users in this forum). ...
9
votes
0answers
90 views

How to implement graph neural networks in Mathematica?

Graph neural networks are useful for prediction tasks like predicting walks. In python I use DeepGraph typically, but I'm wondering what can be done in the new Version 12. Here's a nice introduction ...
2
votes
1answer
57 views

Find critical radius in percolation

I would like to examine the percolation from the left edge to the right edge on random lattice. Suppose I have a rectangle with N random points on it. ...
3
votes
2answers
55 views

Issue with displaying a tree graph after deleting a vertex

Say, I have an expression tree: g = IGExpressionTree[ {{{1,2},{{3,4},{5,6}}},7}, VertexLabels -> "Name"] From that tree I want to delete all the vertices ...
2
votes
1answer
51 views

Coloring and Properties for Individual Edges of a Graph

I have simple graph I am trying to explore to see how I can control various properties of a TreeGraph. For example, within the following function call, I have found out how to color individual ...
1
vote
1answer
70 views

Clustering edge points of an image?

Consider the following image I would like to cluster the points obtained after edge detection and subsequently, would like to color the clustered edge points. My attempt: ...
1
vote
0answers
39 views

Keeping associative bracketing in place [closed]

The following Mathematica code displays the vertices of a given graph after converting an expression into a suitable format (using heads that are tensor and parallel notation. The labels are displayed ...
4
votes
2answers
64 views

Adding edges to a TreeForm of an expression

Say I have an expression {1,{{2,3},4}}. It's TreeForm looks as follows: {1,{{2,3},4}} //TreeForm Now, on each level of that ...
0
votes
1answer
28 views

How to find disjoint subsets such that union of the sets give the motherset or main set?

Let us define a set $\mathcal{S}=\{1,2, 3,\cdots,67\}$. I have a list of 132 subsets. I want to obtain 16(or 17) mutually exclusive subsets such that union of such 16(or 17) is equal to $\mathcal{S}$...
0
votes
0answers
25 views

How to find mutually exclusive subgraphs from a list a subgraphs to cover all nodes in a graph?

A list of 132 subgraphs (each with 4 nodes) is also available. A given node is available in multiple subgraphs. How can I find 17 subgraphs that are mutually exclusive (i.e., one node can be present ...
0
votes
0answers
54 views

Generating all possible subgraphs from an adjacency matrix

I have an adjacency matrix given by am. I want to generate all possible subgraphs with 6 nodes. Here is the code I am using to generate them. But, I am getting some error: ...
6
votes
3answers
486 views

Coloring lines in a graph the same color if they are the same length

If one has a graph with any number of points, as in the example below, how can one color all the lines that are of the same length in the same color? (The points are ...
1
vote
0answers
76 views

Visualizing a huge weighted graph

Consider a weighted graph 'net': ...