liveBook · Manning

Node

As explained in Optimization Algorithms: AI techniques for design, planning, and control problems

A vertex is a node in a graph that can be connected to other vertices by edges.

A node, also called a vertex, is an entity in a graph. Edges connect nodes to represent relationships, routes, dependencies, or other interactions. Unlike elements in a linear structure such as an array or queue, nodes participate in a nonlinear network. section 3.1

Nodes can represent different entities and participate in several graph forms:

  • In an undirected graph, nodes connect through bidirectional edges. section 3.1
  • In a directed graph, nodes connect through directional edges representing flows, causal relations, or dependencies. section 3.1
  • A multigraph can contain several parallel edges between the same nodes, while a hypergraph can connect more than two nodes with one hyperedge. section 3.1
  • Weighted graphs attach values such as distance, travel time, capacity, or fuel consumption to edges between nodes. section 3.1 section 4.4

Routing network

For a route between Queen’s Park and the Bahen Centre, intersections and points of interest—including the origin and destination—become nodes. Road segments become weighted edges, with weights such as distance, travel time, fuel consumption, or number of turns. section 4.4

Listing 3.1 Creating an undirected graph using NetworkX
import networkx as nx
import matplotlib.pyplot as plt
 
graph = nx.Graph()
 
nodes = list(range(5))                        #1
graph.add_nodes_from(nodes)
 
edges = [(0,1),(1,2), (1,3), (2,3),(3,4)]     #2
graph.add_edges_from(edges)
 
nx.draw_networkx(graph, font_color="white")

Create five numbered nodes with NetworkX, connect them through an edge list, and draw the resulting undirected graph. section 3.1

How Optimization Algorithms: AI techniques for design, planning, and control problems covers it

How deep it goes
Defines nodes, distinguishes graph types, demonstrates NetworkX construction, and applies nodes to weighted routing networks.
Examples
Uses NetworkX node lists, social-media entities, and University of Toronto road intersections and points of interest.
What you can do after
Build it from scratch with NetworkX by creating nodes, connecting edges, and visualizing a graph.
How it connects
Connects nodes with edges, graph representations, graph search, shortest-path algorithms, routing, dependencies, and weighted graphs.

Also explained in

Compare how 19 books explain node →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Optimization Algorithms: AI techniques for design, planning, and control problems. The section links point to the parts of the book it draws on.