# 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,489 questions
Filter by
Sorted by
Tagged with
4k views

### Automatically generating a dependency graph of an arbitrary Mathematica function?

Has anyone written a function to pull the function dependencies of a function? That is, it would be nice to have a function that returns a list of function dependencies as a set of rules, terminating ...
11k views

### How can I use Mathematica's graph functions to cheat at Boggle?

Boggle is a word game played with 16 dice and a 4x4 tray. This question is inspired by a Stack Overflow question about Boggle that I decided to solve using Mathematica. In addition to Mathematica, I ...
4k views

### Finding a percolation path

I would like to examine percolation on a random lattice. To be exact, I wish to find the minimum length of a 'bond' needed such that the leftmost site can be connected to the rightmost site. Here is ...
14k views

### Custom arrow shaft

Inspired by Sjoerd C. de Vries' nice answer to this question, and the desire to pimp a Graph I did with Mathematica recently I would like to know if there are ways to customize the arrow's shaft ...
10k views

### How to generate a random tree?

Is it possible to generate a random tree without explicitly constructing a random adjacency matrix that satisfies tree properties? How about a random directed tree? Edit: incredible answer by ...
6k views

### How to get graph layout that reflects edge weights?

My heart soared to discover that Mathematica 8 offers support for specifying a weighted adjacency matrix in WeightedAdjacencyGraph. But it seems that, regardless of the weights between edges, the ...
8k views

### Trying to visualize the Collatz conjecture

I happen to have this collatz collatz[x_, y_] := If[x == 3*y || x == 2*y + 1 || y == 3*x || y == 2*x + 2, 2, 0] So i want a visual 3D adjacency graph of my ...
3k views

### Longest path in 0/1 matrix

I have a matrix of 0's and 1's forming a number of disjoint paths:   I would like to find the lengths of the paths, and from that "spectrum," the longest length (in the above example: 27, ...
7k views

### Finding all shortest paths between two vertices

The built-in FindShortestPath and GraphDistance functions find the shortest path between two particular vertices in a graph. I ...
4k views

### How to plot planar graphs as such?

A planar graph is a graph that can be drawn in the plane such that no two edges cross. For example, the graph ...
2k views

### Visualize an irrational number

I would like to visualize an irrational number like the square root of 2 with Mathematica. I found this visualization of Pi in the internet and wonder how this ...
3k views

### Finding the likeliest path in a Markov process

With Mathematica 9, we have the addition of various processes, among which the discrete Markov process. Given a transition probability matrix m, such a process is ...
3k views

### Generating graphs interactively (GUI)

I want to create graphs interactively using a GUI. I thought of using a ClickPane[] environment. The code I have (in part borrowed from the Documentation) works ...
1k views

### Visual representation of a Ranking over time (image provided)

[Disclaimer: I initially posted this question on stackOverflow 2 months ago and think it might be better suited for this forum (link to original question)] The graph below shows a ranking of ...
1k views

### How to Make a Sankey Diagram

I have two lists start = {{1},{1},{1},{2},{3},{1}} end = {{1},{2},{2},{3},{3},{1}} And I want to create a Sankey diagram. Which looks something like So, ...
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 ...
2k views

### Drawing pairs (planar graph, circle packing)

Circle packing theorem states: For every connected simple planar graph G there is a circle packing in the plane whose intersection graph is (isomorphic to) G. How to use Mathematica to draw examples ...
2k views

### How can I conveniently call igraph from Mathematica?

Mathematica has lots of functions for working with graphs and networks, but there are still some functionality holes that are provided by other packages. Also, due to the nature of graph theory, ...
2k views

### Graph vs. GraphPlot

What is the difference (in purpose) between Graph and GraphPlot? Which function is bested suited to which tasks? Background: I ...
2k views

### Finding a “not-shortest” path between two vertices

In designing a routine for making a simple three dimensional (5x5x5) labyrinth, I realized that my solutions (a solution is a labyrinth includes a single path from {1, 1, 1} to {5, 5, 5} in a 5 x5x5 ...
5k views

### Is there a way to convert an image into a Graph?

I'm trying to convert an image with several overlapping dots into a Graph. The goal is to be able to derive the Kirchhoff matrix for the randomly created "network ...
1k views

### Visualizing Rubik's Graph

After the August 2010 discovery that the diameter of the Rubik graph is 20, I wanted to make a way to visualize Rubik's graph. Since there are about $4.3 \times 10^{19}$ vertices in this graph, it is ...
693 views

### How to get complete Documentation Center graph of guide pages?

On the very last image below you can see a typical path of walking through Documentation Center guide pages. What is the best way to get the graph data and visualize the whole structure of these ...
3k views

### Cycles of length N in a graph

If I have an undirected graph represented with an adjacency matrix, how can I find all the subgraphs which are a cycle of length N? I don't really know the math nor the programming language well, so ...
2k views

### How to divide the wine into two equal portions?

There is a 8-liter bottle is full of wine. There are two empty bottles that have capacity 5-liters and 3-liters. How can these three bottles be used to separate the wine into two 4-liter portions? ...
3k views

### How can we produce a graph layout with hierarchical edge bundling in Mathematica?

I'm looking to reproduce the types of graph layout that are possible in D3 (http://bl.ocks.org/mbostock/7607999) in Mathematica. Since Mathematica doesn't explicitly support force directed edge ...
7k views

### How to play with Facebook data inside Mathematica?

I saw this post from Wolfram here and I would like to know how to import facebook data into Mathematica.
1k views

### How to visualize large graphs with directed edge bundling?

I'm wondering if anyone has implemented edge bundled graph plotting? An important paper is "Force-Directed Edge Bundling for Graph Visualization" by Danny Holten and Jarke J. van Wijk.
1k views

### Reduce distances between vertices of graph to minimum possible?

This simple graph has vertex shapes of different sizes: ...
2k views

### How to create regular (planar) graphs?

How to programmatically create and plot regular planar graphs with $k = 3, 4$ or $6$ (not hypercubes) and regular nonplanar graphs of $k = 8$ (see figure)? Note that what matters is the average ...
1k views

### How to plot planar graphs in a visually pleasing way?

Cross posted to Wolfram Community Mathematica has a layout algorithm to plot planar graphs without edge crossings. This typically produces an ugly triangular layout where some vertices and edges are ...
978 views

### Strategies for solving problems involving searches

As an example of a search-oriented problem, consider finding all constrained $n$-colorings of a graph. An "$n$-coloring" associates one of $n \ge 1$ colors to each vertex in such a way that no edge ...
3k views

### Creating diagrams for category theory

Lately I've been doing algebra and I have found myself drawing a bunch of diagrams when I attempt to solve a problem. Most of the diagrams are very simple so I thought, I bet I can do this in ...
807 views

### Import and Plot Git Commit History

What might be the easiest to import and plot all commit history for a github project? I'm looking for something similar to the following.
1k views

### Graph layout on a grid

Is it possible for Mathematica to layout a graph so that the connections lie on a grid? Furthermore, for graphs with multiple edges per vertex, is it possible to specify the location on the vertex ...
998 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 ...
8k views

### Solving the Travelling Salesman Problem

I've been trying to find some kind of mathematical computer software to solve the Travelling Salesman Problem. The Excel Solver is able to do it, but I've noticed there is a built-in function in ...
556 views

### Packed Graph or GraphPlot output with non-square layout?

Graph or GraphPlot produce square layouts for disconnected graphs: Graph[Table[i -> Mod[i^3, 100], {i, 1, 100}]] I´d like to get a rectangular layout with e.g....
3k views

### How can I construct and visualize a hypergraph?

A hypergraph is a generalization of a graph, in which an edge can connect more than two vertices. Thus you can think of an edge in an hypergraph as a subset of nodes. Since version 8, Mathematica has ...
768 views

### Reconstruct a graph from an image (curved edges and edge crossings)

Actually, I posted a very similar question before this.How to generate a Graph from a picture of a graph Dr. belisarius's answer have answered that question, but I find a limitation in that method: ...
970 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.
1k views

### How to build a 3D graph from a 3D matrix?

Following this and that question and the corresponding answers, Mathematica can build 2D graph from 2D matrices. Question How to make the corresponding 3D graphs from 3D cubes? Attempt ...
386 views

### Framework behind Graph plots. DynamicNamespace and friends

As shown in DynamicLocation usage, we can use it to quickly create very nice functionality, that it to refer to graphics' primitives relative coordinates without calculations of boundary etc. As ...
938 views

### Why would the color of graph change once the number of vertexes reach 1000?

I have created 3 graphs for vertexes number 998, 999 and 1000 as below:- ...
483 views

Bug introduced in 10.0 and persisting through 12.0 TransitiveReductionGraph is new in 10.0. In Mathematica 10.0 and 10.1, according to the documentation of ...
2k views

### Graph from binary matrix (not adjacency) respecting the original matrix positions

I have a binary matrix. My objective is to connect every close (without "jump") elements with value equal to 1, but I must keep the point positions, just like it's shown at the image. Can somebody ...
10k views

### How to generate random directed acyclic graphs?

How to programmatically build random directed acyclic graphs (DAG)? I know about the AcyclicGraphQ predicate and the ...
677 views

### HighlightGraph Problem

Bug introduced in 9.0 or earlier and fixed in 11.3 HighlightGraph does not work. ...