Installation
Installation
The simplest way to automatically download and install the latest release of IGraph/M is to evaluate the following line in Mathematica:
In[]:=
Get["https://raw.githubusercontent.com/szhorvat/IGraphM/master/IGInstaller.m"]
The currently installed versions of IGraph/M are: {}
Installing IGraph/M is complete: PacletObject.
It can now be loaded using the command
To install IGraph/M manually, or to install a different version than the latest one, download the.paclet file from the GitHub releases page, and install it using the PacletInstall Mathematica function. For example, ifIGraphM-0.6.2.paclet was downloaded into the directory ~/Downloads, then evaluate
Needs["PacletManager`"]PacletInstall["~/Downloads/IGraphM-0.6.2.paclet"]
If the .paclet file was downloaded to a different location, adjust the path above accordingly.
It is not necessary to uninstall old versions before installing a new one.
A more detailed guide for installing packages distributed in the paclet format is available on StackExchange.
Once installed, test that it works with a few simple commands:
It is not necessary to uninstall old versions before installing a new one.
A more detailed guide for installing packages distributed in the paclet format is available on StackExchange.
Once installed, test that it works with a few simple commands:
In[]:=
<<IGraphM`
Out[]=
IGraph/M 0.6.2 (July 25, 2022) |
Evaluate |
In[]:=
IGVersion[]
Out[]=
IGraph/M 0.6.2 (July 25, 2022)igraph 0.9.9-68-g0c33f892b (Jul 25 2022)Microsoft Windows (64-bit)
In[]:=
Graph[GraphData["DodecahedralGraph"],EdgeStyle->Directive[Thick,Opacity[1]],VertexStyle->Black]//IGEdgeMap[ColorData[109],EdgeStyle->IGEdgeColoring]
Out[]=
Showcase
Showcase
Featured examples
Featured examples
Create a random maze as a random spanning tree of a regular lattice confined to a hexagon, and colour it according to betweenness centrality:
In[]:=
g=IGMeshGraph@IGLatticeMesh["CairoPentagonal",Polygon@CirclePoints[6,6]];t=IGRandomSpanningTree[g,VertexCoordinates->GraphEmbedding[g],GraphStyle->"ThickEdge"];IGEdgeMap[ColorData["Rainbow"],EdgeStyle->IGEdgeBetweenness/*Rescale,t]
Out[]=
Compute and visualize a minimum vertex and edge colouring of the Gabriel graph of a set of spatial points:
In[]:=
IGGabrielGraph[RandomPoint[Disk[],30],GraphStyle->"Monochrome",VertexSize->1,EdgeStyle->Thickness[1/40]]//IGVertexMap[ColorData[106],VertexStyle->IGMinimumVertexColoring]//IGEdgeMap[ColorData[106],EdgeStyle->IGMinimumEdgeColoring]
Out[]=
Mesh/graph conversions
Mesh/graph conversions
Let us take a polyhedral mesh.
In[]:=
mesh=PolyhedronData["TruncatedIcosahedron","BoundaryMeshRegion"]
Out[]=
It is easy to convert it to a graph.
In[]:=
g=IGMeshGraph[mesh]
Out[]=
We could also easily convert it to a face-adjacency graph, or an edge-adjacency graph
In[]:=
(*facetofaceadjacency,preservingcoordinates*)IGMeshCellAdjacencyGraph[mesh,2,VertexCoordinatesAutomatic]
Out[]=
Graph symmetries
Graph symmetries
This is a very symmetric graph. The graph structure looks exactly the same when viewed from any vertex. In other words, the graph is vertex-transitive.
The same is not true for edges though.
There are in fact two types of edges: those separating a hexagonal face from a pentagonal one, and those separating two hexagonal faces. We can visualize them:
How many symmetries (automorphisms) does the graph have?
Planarity
Planarity
This is also a planar graph.
We can find all its faces.
Each list in the result contains the ordered vertices of a face.
We can also compute a Tutte layout of the graph, with an arbitrary choice of outer face. A planar graph can be drawn with any of its faces being the outer face.
We can not only find the faces of this planar graph, we can also compute its dual graph.
Or find a combinatorial embedding, i.e. a counterclockwise ordering of neighbours around each vertex.
Graph colouring
Graph colouring
Let us compute a minimum vertex colouring of the dual graph. Since it is planar, we know that it is possible in at most 4 colours.
It was indeed necessary to use 4 colours.
The original graph, however, can be both vertex-coloured and edge-colored using only 3 colours.
The vertex colouring of the dual graph of a polyhedral skeleton is actually a face colouring of the polyhedron. Let us visualize the colouring like this.
Proximity graphs
Proximity graphs
Earlier, we computed a nice layout for this graph. Can we reconstruct the graph from the coordinates of this layout?
The concept of the relative neighbourhood graph was developed to model human perception of a set of points. Let us compute both this graph, and the Gabriel graph.
The connections we get this way are not the same as the original graph, but at least in the middle of the point set, the connections are reconstructed well.
β-skeletons are proximity graphs that interpolate smoothly between the two graphs above, and beyond.
Let us construct a random maze from the Gabriel graph of these points by taking a random spanning tree.
An exact definition of all of these proximity graphs used above is found in the IGraph/M documentation. Open it to see many more functions with many more examples by evaluating: