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.

0
votes
1answer
40 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 ...
0
votes
2answers
39 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
29 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
62 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 ...
8
votes
2answers
668 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
31 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
176 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
73 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
47 views

How can I parametrically generate a hierarchically clustered network?

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
45 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
195 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
40 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
44 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
30 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
56 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 ...
4
votes
2answers
62 views

How to add SwtachLegend to a graph?

I created a random graph with each vertex colored randomly. I would like to add a SwtachLegend to the graph to indicate the value corresponding to a color. How can I do that? Here's my code for the ...
3
votes
1answer
165 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
27 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
67 views

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

Consider the edges ...
2
votes
1answer
31 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
230 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). ...
7
votes
0answers
82 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
54 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
54 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
41 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
64 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
37 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
63 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
27 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
24 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
53 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
475 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
75 views

Visualizing a huge weighted graph

Consider a weighted graph 'net': ...
4
votes
0answers
55 views

Four color theorem in Mathematica [closed]

The four color theorem is a theorem about graphs (as in graphs and networks) and it was proved with the aid of a computer. To date, there is no hand-checkable proof. The software that was used to ...
3
votes
1answer
287 views

Is there a way to generate a mapping graph like this?

I am wondering whether there are any functions in Mathematica that can generate mapping graphs like the one shown below.
10
votes
3answers
515 views

How to get all possible paths in 0/1 matrix better way?

This picturel can be generated like this ...
1
vote
0answers
23 views

How to generate a DAG with given number of node and edge? [duplicate]

The node of the graph is n,edge of the graph is m: How can I generate a DAG randomly with node n and edge m?
0
votes
1answer
43 views
10
votes
2answers
164 views

Find all edge self-avoiding path of a graph

In Mathematica, we can use FindPath[graph, start, end, Infinity, All] to find all self-avoiding paths, which means the path can not cross vertex and edge repeatedly....
3
votes
2answers
77 views

Can I direct an edge to the midpoint of another edge in a graph?

I've been trying to make graphs in which I can direct an edge to the midpoint of another edge, as in the following figure: So far, what I've tried, (far from ideal, especially with bigger networks), ...
5
votes
4answers
460 views

Histogram using edges

I have a list of directed edges: ...
7
votes
3answers
281 views

TreeGraph construction

I have a list l={{1,1},{2,3},{2,3,2,3,4}}. Based on that list, I want to draw a tree. Starting from a single point at the top of a tree, I proceed as follows, using ...
1
vote
1answer
49 views

How to customize ListPolarPlot axes?

I am trying to make a polar graph of star positions. My current code is ...
5
votes
1answer
86 views

Is there a curved EdgeShapeFunction that has arrowheads?

The undocumented "CurvedArc" EdgeShapeFunction draws edges as curves (instead of straight lines). However, it does not draw ...
4
votes
2answers
141 views

Tree-like diagram with text as VertexLabels

I am searching Mathematica's Documentation about TreePlot and relevant functions but I cannot find the solution to my question. Say ...
5
votes
0answers
84 views

Graph problem with IGraphM package

Consider the graph: ...
1
vote
1answer
56 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
62 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
211 views

How to find 'n' nodes where all distances between them are greater than 'k'?

Consider the weighted graph 'net1': ...
20
votes
1answer
865 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.