Mexico City Subway Network

Source Notebook

The Mexico City subway network

Details

The Mexico City subway network, officially known as the "Sistema de Transporte Colectivo" (STC) or the Mexico City Metro, is the network of interconnected subway lines that serves the metropolitan area of Mexico City and some municipalities in the State of Mexico.
Each subway station is a vertex, and the connections between stations are represented as edges (163 vertices, 183 edges)
The subway lines are numbered from 1 to 9, A, B, and 12.
Geolocation data is incorporated into the vertices to represent the precise positions of each station.
Information about passenger usage is represented as weights of the vertices. It's noteworthy that some stations have a weight of zero, such as those on line 1, which is undergoing maintenance, and those on line 12, that had an incident on 2021.

(163 vertices, 183 edges)

Examples

Basic Examples (4) 

Retrieve the graph:

In[1]:=
ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\)]
Out[1]=

Retrieve one of the lines:

In[2]:=
Graph[ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\), "Line 1"], EdgeStyle -> ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\), "Colors"], VertexStyle -> White]
Out[2]=

Find the vertex count for the network:

In[3]:=
VertexCount[ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\)]]
Out[3]=

Find the edge count for the network:

In[4]:=
EdgeCount[ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\)]]
Out[4]=

Visualizations (4) 

Visualize the vertices with more connections:

In[5]:=
g = ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\)];
In[6]:=
Graph[g, VertexSize -> Thread[VertexList[g] -> (VertexDegree[g]/Median[VertexDegree[g]])], GraphLayout -> "RadialEmbedding", EdgeStyle -> ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\), "Colors"]]
Out[6]=

Visualize the vertices with more affluence:

In[7]:=
g = ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\)];
In[8]:=
Graph[g, VertexSize -> Map[# /. (x_ -> y_) :> (x -> y/1000000) &, ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\), "VertexWeight"]], EdgeStyle -> ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\), "Colors"], VertexStyle -> White]
Out[8]=

Visualize the GeoPositions with GeoGraphPlot:

In[9]:=
GeoGraphPlot[EdgeList[ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\)]] /. ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\), "GeoPositions"]]
Out[9]=

Visualize the different lines with GeoGraphPlot:

In[10]:=
indgraph2 = GeoGraphPlot[EdgeList[ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\), #]] /. ResourceData[\!\(\*
TagBox["\"\<Mexico City Subway Network\>\"",
#& ,
BoxID -> "ResourceTag-Mexico City Subway Network-Input",
AutoDelete->True]\), "GeoPositions"], GeoRange -> {GeoPosition[{19.53983345875487, -99.22046756934368}],
       GeoPosition[{19.279964832166694`, -98.95502497470883}]}, PlotLabel -> #] & /@ {"Line 1", "Line 2", "Line 3", "Line 4", "Line 5", "Line 6", "Line 7", "Line 8", "Line 9", "Line A", "Line B", "Line 12"}
Out[10]=

Wolfram Discrete Computation, "Mexico City Subway Network" from the Wolfram Data Repository (2025)  

Data Resource History

Source Metadata

Publisher Information