Advanced Data Structure

Chapter 8
Graph Representations and Advanced Graph Structures

Post Graduate Program in AI and ML
Advanced Data Structure   •   Post Graduate

Graph Representations and Advanced Graph Structures

Introduction

Graphs provide a general language for representing relationships. In artificial intelligence and machine learning, vertices may represent users, documents, molecules, web pages, sensors, or entities, while edges may represent friendship, similarity, chemical bonding, hyperlinks, communication, or logical relations. The same abstract graph can support very different computational workloads. A recommendation system may repeatedly traverse neighbors; a route planner may solve weighted shortest-path problems; a graph neural network (GNN) may perform repeated sparse matrix–vector operations; and a knowledge graph may require dynamic updates and rich edge attributes.

The choice of graph representation is therefore an algorithm-engineering decision rather than a mere programming detail. It affects memory consumption, cache behavior, update cost, parallelism, numerical precision, and the feasibility of large-scale learning.

A graph is written as G = (V, E), where V is the set of vertices and E is the set of edges. Let n = |V| and m = |E|. A directed edge is an ordered pair (u, v); an undirected edge is an unordered pair {u, v}. A weighted graph associates a weight w(u, v) with each edge. Unless stated otherwise, self-loops are excluded and parallel edges are not assumed.

Learning Objectives

After completing this chapter, the reader should be able to:

  1. Distinguish adjacency matrices, adjacency lists, edge lists, and compressed sparse representations.
  2. Select a representation according to graph density, workload, update pattern, and hardware.
  3. Explain advanced structures such as CSR, CSC, COO, packed bitsets, dynamic adjacency structures, and temporal graphs.
  4. Relate representations to BFS, DFS, shortest paths, connected components, centrality, and spectral methods.
  5. Explain why GNN workloads usually use sparse neighborhood representations.
  6. Evaluate scalability, numerical, privacy, and governance issues in graph systems.

1. Graph Models and Structural Properties

The degree of a vertex v in an undirected graph is the number of incident edges and is denoted deg(v). In a directed graph, indeg(v) counts incoming edges and outdeg(v) counts outgoing edges. The sum of degrees in an undirected graph satisfies the handshaking identity:

∑v∈V deg(v) = 2m

Each undirected edge contributes two incidences. For a directed graph, the corresponding sums are ∑ indeg(v) = m and ∑ outdeg(v) = m. A simple undirected graph has at most n(n − 1)/2 edges, so density may be defined as:

d = 2m / [n(n − 1)]

where 0 ≤ d ≤ 1. For a directed simple graph without self-loops, the denominator is n(n − 1). Density is a useful first indicator, but degree distribution is often more informative. Social and information networks are frequently sparse overall but contain high-degree hubs, producing skewed or heavy-tailed degree distributions.

Graph structure also includes connectivity, paths, cycles, components, bipartiteness, diameter, and clustering. These properties influence both algorithmic complexity and data layout. A graph with millions of vertices may still be computationally manageable if m is proportional to n, whereas a dense matrix may be impossible to store.

2. Fundamental Representations

2.1 Adjacency Matrix

An adjacency matrix A is an n × n array. For an unweighted directed graph,

Aij = 1 if (i,j) ∈ E; otherwise Aij = 0

For a weighted graph, Aij stores the edge weight, with a separate convention for the absence of an edge. In an undirected graph, A is symmetric: Aij = Aji. A self-loop appears on the diagonal.

The storage requirement is Θ(n²), independent of m. Testing whether an edge exists takes O(1), and inserting or deleting an edge also takes O(1), assuming the matrix is already allocated. Enumerating all neighbors of one vertex requires scanning an entire row and therefore costs O(n). Matrix-based algorithms can be highly efficient on dense graphs and on hardware optimized for linear algebra.

A major issue is the representation of missing weighted edges. Using zero is unsafe when zero-weight edges are valid. Alternatives include a Boolean mask, positive infinity for shortest-path initialization, or a distinguished null value. Numerical algorithms must not confuse absence with a legitimate weight.

2.2 Adjacency List

An adjacency list stores, for each vertex, a collection of its neighbors. For a weighted graph, each entry commonly contains (neighbor, weight). An undirected edge is stored twice, once in each endpoint's list, unless a specialized shared-edge structure is used.

The space requirement is Θ(n + m) for unweighted graphs, with additional implementation overhead for pointers, object headers, or dynamic containers. Neighbor enumeration costs O(deg(v)); testing for a particular edge costs O(deg(v)) in an unsorted list, or approximately O(1) expected time with hashing. Sorted lists support binary search but make insertion more expensive.

Adjacency lists are usually the default representation for sparse static graphs. BFS and DFS naturally scan each vertex and each adjacency entry once, giving O(n + m) time. However, pointer-heavy lists can have poor cache locality, and Python-style object representations may use far more memory than the theoretical bound suggests.

2.3 Edge List

An edge list stores edges as records such as (u, v) or (u, v, w). It is simple, compact, and convenient for ingestion, interchange, sorting, and algorithms that process every edge. For example, Kruskal's minimum spanning tree algorithm requires edges sorted by weight.

An edge list is inefficient for neighborhood queries: finding all neighbors of v may require scanning all m edges, costing O(m). It is therefore often an input or archival representation rather than the primary operational structure. In distributed systems, edge lists are useful for batch processing because records can be partitioned by source, destination, or key range.

2.4 Incidence Matrix

An incidence matrix B relates vertices to edges. For an undirected graph, Bij is commonly 1 when vertex i is incident to edge j and 0 otherwise. Each ordinary edge column contains two ones. A signed incidence matrix for an oriented graph uses −1 at the source and +1 at the destination. Incidence matrices are useful in flow, electrical-network, and topological formulations, but require Θ(nm) storage and are rarely the primary representation for large sparse graphs.

3. Compressed Sparse Representations

Sparse graph structures seek the memory efficiency of lists while improving locality and vectorized processing.

3.1 Coordinate Format (COO)

COO stores parallel arrays such as row, column, and value. An edge (u, v, w) is represented by row[k] = u, col[k] = v, and val[k] = w. COO is easy to construct and concatenate, which makes it useful during data ingestion and minibatch assembly. Duplicate entries may be retained temporarily and later summed or coalesced. Neighbor lookup is not efficient until COO is converted to a more structured format.

3.2 Compressed Sparse Row (CSR)

CSR stores three arrays:

  • values: the edge weights or data;
  • column_indices: the destination vertex of each stored edge;
  • row_ptr: offsets into the first two arrays.

For vertex u, its outgoing edges occupy indices row_ptr[u] through row_ptr[u + 1] − 1. Thus the number of outgoing edges is:

deg⁺(u) = rowptr[u+1] − rowptr[u]

The row pointer array has length n + 1, while the other arrays have length m for a graph with one stored record per directed edge. Storage is Θ(n + m), with compact primitive arrays and excellent sequential access. CSR is especially effective for sparse matrix–vector multiplication and source-oriented traversal.

A CSR matrix–vector product computes:

yu = ∑k=rowptr[u]rowptr[u+1]−1 values[k] × xcolumnindices[k]

Here x and y are vectors, and the operation assumes that each stored record represents a matrix entry. For an adjacency matrix, this aggregates values from the source vertex's outgoing neighbors according to the chosen matrix orientation.

CSR is efficient for reading and traversal but expensive for arbitrary insertion because inserting an item may shift many array elements. It is therefore best for static or periodically rebuilt graphs.

3.3 Compressed Sparse Column (CSC)

CSC is the column-oriented counterpart. It supports efficient access to incoming neighbors and column-based sparse linear algebra. For directed graphs, CSR is naturally suited to outgoing-neighbor operations, whereas CSC is suited to incoming-neighbor operations. Many systems maintain both when algorithms require frequent access in both directions, approximately doubling edge storage.

3.4 ELLPACK and Blocked Formats

ELLPACK stores a fixed number of entries per row, padding shorter rows. It can provide regular memory access and strong GPU performance when row lengths are similar. Power-law graphs often have highly unequal degrees, so padding can waste substantial memory. Hybrid formats, such as a combination of ELLPACK for regular rows and COO or CSR for irregular rows, attempt to balance regularity and space efficiency. Blocked sparse formats exploit local groups of nonzero entries and are useful when graph or feature data exhibits block structure.

4. Representation Comparison

RepresentationSpaceEdge testNeighbor scanUpdatesTypical use
Adjacency matrixΘ(n²)O(1)O(n)O(1)Dense graphs, small graphs, fast pair queries
Unsorted adjacency listΘ(n + m)O(deg(v))O(deg(v))Usually easySparse traversal and dynamic graphs
Hash adjacencyΘ(n + m) plus overheadO(1) expectedO(deg(v))O(1) expectedFrequent online updates
Edge listΘ(m)O(m)O(m)Append-friendlyIngestion, sorting, batch processing
CSRΘ(n + m)Often O(deg(v))O(deg(v))Poor arbitrary insertionStatic sparse graphs, GNNs, SpMV
CSCΘ(n + m)Often O(indeg(v))O(indeg(v))Poor arbitrary insertionReverse traversal, column operations
Bitset matrixΘ(n² / word size)O(1) bit accessO(n / word size)Fast bit operationsDense or moderately dense unweighted graphs

Theoretical complexity does not fully determine performance. A contiguous CSR array may outperform a theoretically similar linked list because of cache locality. Conversely, CSR rebuilding can dominate runtime in streaming applications. Representation should therefore be selected from an observed workload, not from asymptotic notation alone.

5. Dynamic, Temporal, and Heterogeneous Graphs

Dynamic Graphs

A dynamic graph changes through edge or vertex insertions and deletions. A common design is a base-plus-delta structure: a compact immutable CSR base stores most edges, while recent updates are held in writable hash tables or buffers. Periodically, the delta is merged into a new base. This approach avoids shifting CSR arrays on every update but introduces merge cost and temporary duplication.

Fully dynamic adjacency may use hash maps for rapid updates. The trade-off is higher memory overhead, nondeterministic iteration order, and weaker locality. Deletions may be represented by tombstones until compaction. Systems must define consistency semantics: whether a query sees all updates immediately, only committed updates, or a snapshot.

Temporal Graphs

In temporal graphs, an edge has a validity interval or timestamp, such as (u, v, t) or (u, v, [t_start, t_end]). A time-respecting path must obey nondecreasing event times. Temporal storage may be organized by source and time, by time windows, or in a bitemporal design that distinguishes event time from system-ingestion time. This distinction is important in fraud detection and audit systems, where late-arriving data must not be confused with the time at which an event occurred.

Property, Heterogeneous, and Knowledge Graphs

A property graph stores attributes on vertices and edges, such as a user's age or a transaction's currency. A knowledge graph commonly uses typed triples (subject, predicate, object), for example (drug, treats, disease). Since predicates and entity types affect query semantics, a single untyped adjacency matrix may lose essential information. Practical systems use dictionaries for identifiers, partitioned indexes by relation type, and compressed columns for attributes.

A heterogeneous graph has multiple node and edge types. Its representation may include one adjacency structure per relation type, a typed edge table, or a block adjacency matrix. Relation-specific structures are particularly important for relational GNNs, which apply different transformations to different edge types.

6. Representations and Core Algorithms

Traversal

BFS uses a queue and explores vertices in nondecreasing distance from a source in an unweighted graph. With adjacency lists or CSR, its time complexity is O(n + m), assuming constant-time marking and queue operations. An adjacency matrix usually causes O(n²) scanning across all rows, even when few edges exist.

DFS has the same O(n + m) bound with a sparse neighbor representation. It supports cycle detection, topological sorting, articulation-point analysis, and component discovery. Iterative implementations avoid call-stack overflow on deep graphs.

Shortest Paths

For nonnegative edge weights, Dijkstra's algorithm is typically implemented with adjacency lists or CSR and a priority queue. With a binary heap, a common bound is O((n + m) log n), though exact bounds depend on implementation and decrease-key handling. A matrix implementation that scans all possible neighbors is often appropriate only for dense graphs.

Bellman–Ford supports negative edge weights and detects reachable negative cycles, but requires O(nm) time in its standard form. Floyd–Warshall computes all-pairs shortest paths in O(n³) time and Θ(n²) storage, making it appropriate for small or dense graphs rather than web-scale sparse networks.

Weights must be interpreted carefully. Dijkstra's algorithm is not valid when a reachable edge has negative weight. In a knowledge graph, edge labels may not be numerical costs at all; semantic relation types should not be silently treated as distances.

Connectivity and Network Analysis

Connected components can be found by DFS, BFS, or disjoint-set union. Strongly connected components in directed graphs can be computed by algorithms such as Kosaraju's or Tarjan's, typically in O(n + m). Reverse traversal requires either incoming adjacency or an efficiently constructed transpose graph; this is one reason systems sometimes maintain both CSR and CSC.

PageRank illustrates a sparse linear-algebra workload. A simplified random-surfer update is:

pt+1 = αPᵀpt + (1 − α)v

Here p_t is a probability vector, P is a row- or column-stochastic transition matrix according to the convention used, α is the damping factor with 0 < α < 1, and v is a teleportation distribution whose entries sum to 1. The orientation and treatment of dangling vertices must be specified. Sparse matrix–vector multiplication makes CSR or CSC preferable to a dense matrix for sparse web graphs.

7. Graph Neural Network Workloads

A typical GNN layer aggregates representations from neighbors. A simplified message-passing equation is:

hv(ℓ+1) = σ(W0 hv(ℓ) + ∑u∈N(v) W1 hu(ℓ))

Here h_v^(ℓ) is the feature vector of vertex v at layer ℓ, N(v) is its neighborhood, W0 and W1 are trainable matrices, and σ is an activation function. The formula is illustrative; specific models may normalize messages, distinguish edge types, include attention coefficients, or add residual connections.

The central operation is sparse aggregation. Storing the graph as CSR or COO avoids materializing an n × n dense matrix. COO is convenient for scatter-based GPU kernels, while CSR supports row-wise aggregation. For directed or bipartite graphs, the selected orientation must match the desired message flow. A reverse edge may need to be added explicitly if information should travel in both directions.

GNN representation choices also affect:

  • mini-batch sampling and neighborhood expansion;
  • memory transfer between CPU and GPU;
  • duplicate-edge coalescing;
  • handling of high-degree hubs;
  • deterministic training and reproducibility;
  • distributed partitioning and communication volume.

For large graphs, full-batch training may be impossible. Neighbor sampling, cluster partitioning, layer-wise sampling, or subgraph training reduces computation but can introduce sampling bias and variance. A representation should therefore support the chosen training strategy rather than only the original graph query workload.

8. Worked Example: Choosing a Representation

Consider a directed citation graph with n = 1,000,000 papers and m = 5,000,000 citation edges. Assume each CSR edge stores a 4-byte destination identifier and a 4-byte single-precision weight. The row pointer stores 8-byte offsets.

The destination and value arrays require:

  • 5,000,000 × 4 bytes = 20,000,000 bytes each;
  • together, 40,000,000 bytes.

The row-pointer array requires:

  • (1,000,001) × 8 bytes = 8,000,008 bytes.

The total is approximately 48,000,008 bytes, or about 48 MB using decimal units, excluding alignment and metadata.

A dense Boolean adjacency matrix would require 1,000,000² bits if bit-packed, equal to 125,000,000,000,000 bytes, approximately 125 TB. If stored as one byte per entry, it would require approximately 1 PB. Thus the graph's low density makes CSR overwhelmingly more appropriate for traversal and GNN aggregation. However, if the application performs frequent arbitrary edge insertion, a writable delta structure should accompany or temporarily replace CSR.

9. Applied Case: Fraud Detection in a Financial Transaction Network

Background

This illustrative case concerns a financial institution analyzing transfers among accounts. Vertices represent accounts, and directed weighted edges represent transfers. Each edge has amount, currency, timestamp, channel, and risk metadata.

Problem

The institution must identify suspicious cycles, rapidly expanding money-flow communities, and accounts that connect otherwise separate groups. The graph receives millions of new transactions daily, while investigators require both recent and historical views.

Analysis

A single adjacency matrix is unsuitable because the graph is sparse, dynamic, directed, attributed, and temporal. An edge list is useful for ingestion and audit storage but is too slow for repeated neighborhood queries. A static CSR snapshot supports fast traversal and sparse analytics, but it cannot efficiently absorb every update.

Approach

The institution uses a layered design:

  1. An append-only edge log preserves original events for auditability.
  2. A streaming index stores recent transactions by source account and time window.
  3. Periodic CSR and CSC snapshots support high-throughput forward and reverse traversal.
  4. Separate indexes organize edge attributes by timestamp, currency, and channel.
  5. A feature graph feeds a GNN, while rules and classical algorithms provide interpretable alerts.
  6. Snapshot identifiers ensure that an investigation can reproduce the graph state used for a decision.

Cycle detection and strongly connected component analysis identify recurrent flow structures. Weighted shortest-path or constrained path queries estimate how funds may move through intermediaries. Community and centrality measures prioritize cases but do not alone establish wrongdoing.

Outcome

The layered representation balances ingestion, analytics, and reproducibility. Investigators obtain fast queries on recent data and stable historical snapshots. The design also permits model retraining without silently changing the evidence base.

Learning Points

The case demonstrates that representation selection is workload-specific. It also shows why timestamps, provenance, attribute indexes, and versioned snapshots are as important as asymptotic speed in high-stakes graph applications.

10. Engineering, Governance, and Ethical Considerations

Performance and scalability

Benchmark representative workloads: edge existence, neighbor enumeration, traversal, random updates, sparse matrix–vector multiplication, and batch GNN aggregation. Measure latency distributions, memory footprint, throughput, cache misses, serialization cost, and rebuild time. Average latency alone can hide unacceptable tail behavior.

Correctness and numerical issues

Define whether parallel edges are preserved, summed, or rejected. Specify self-loop semantics, vertex identifier stability, missing weights, duplicate handling, and directed-edge orientation. For floating-point weights, document precision and tolerance policies. Reproducible analytics require fixed graph snapshots, deterministic ordering where relevant, and versioned preprocessing.

Privacy and fairness

Relationship data can reveal sensitive associations even when individual attributes are removed. Access control should apply to vertices, edges, attributes, and query results. De-identification is not automatically sufficient because graph structure can enable re-identification. GNNs may amplify historical bias encoded in connectivity patterns. High-impact decisions should include human review, explanation procedures, appeal mechanisms, and monitoring for disparate error rates.

Security

Graph systems are vulnerable to poisoning through fabricated nodes or edges, sybil attacks, adversarial link insertion, and inference attacks. Provenance checks, rate limits, anomaly monitoring, signed data sources, and separation of training from untrusted live updates reduce risk.

11. Best-Practice Selection Framework

A practical decision process is:

  1. Characterize n, m, density, degree distribution, directionality, weights, and attribute volume.
  2. Identify dominant operations: pair queries, neighbor scans, traversal, updates, reverse access, or sparse linear algebra.
  3. Decide whether the graph is static, dynamic, temporal, heterogeneous, or versioned.
  4. Choose compact primitive storage for large static graphs; avoid pointer-heavy objects unless update flexibility justifies them.
  5. Select CSR for source-oriented static access, CSC for destination-oriented access, and both when reverse operations are frequent.
  6. Use COO for construction, interchange, and scatter-oriented computation, converting it when stable access matters.
  7. Separate ingestion, serving, analytical, and machine-learning representations when their workloads differ.
  8. Benchmark with realistic degree distributions and failure conditions.
  9. Record semantics, provenance, version, and preprocessing decisions.
  10. Reassess the design when graph scale or workload changes.

Contemporary Directions

Modern graph platforms increasingly combine compressed sparse storage with accelerators, distributed partitioning, columnar attributes, and streaming updates. GPU systems favor coalesced memory access and may use hybrid sparse formats. Distributed systems partition graphs by vertices or edges, but high-degree vertices can create communication hotspots. Research continues on dynamic GNNs, temporal message passing, graph foundation models, compressed representations, approximate querying, and hardware-aware graph compilation.

No representation is universally optimal. The important professional skill is to map an application’s semantic and computational requirements to a structure whose costs are understood, measured, and governed.

Chapter Summary

Graphs represent entities and relationships, but their computational behavior depends strongly on representation. Adjacency matrices provide constant-time pair access and are suitable for dense or small graphs, while adjacency lists and compressed sparse formats are preferable for large sparse networks. Edge lists are effective for ingestion and whole-edge processing but weak for neighborhood queries.

CSR and CSC provide compact, cache-friendly storage for static sparse graphs; COO is convenient for construction and scatter operations. Dynamic systems often combine immutable compressed snapshots with writable deltas. Temporal, property, heterogeneous, and knowledge graphs require representations that preserve time, attributes, and relation types rather than reducing everything to an untyped matrix.

Traversal and sparse graph algorithms generally scale with O(n + m), whereas dense matrix methods may scale with O(n²) or O(n³). GNNs rely on sparse aggregation, making orientation, duplicate handling, sampling, and accelerator memory behavior central design concerns. In professional settings, performance must be balanced with correctness, provenance, privacy, fairness, security, and reproducibility.

Key Terms

Graph: A structure consisting of vertices and edges.

Vertex: An entity or node in a graph.

Edge: A relationship connecting two vertices.

Adjacency matrix: An n × n array encoding pairwise connections.

Adjacency list: A per-vertex collection of neighboring vertices.

Edge list: A collection of edge records.

CSR: Compressed Sparse Row representation using values, column indices, and row offsets.

CSC: Compressed Sparse Column representation for column-oriented sparse access.

COO: Coordinate sparse format storing row, column, and value arrays.

Degree: Number of incident edges; in directed graphs, incoming and outgoing degree are distinguished.

Graph density: The proportion of possible edges that are present.

Sparse matrix–vector multiplication: Multiplication exploiting mostly absent matrix entries.

Dynamic graph: A graph subject to insertions, deletions, or changing attributes.

Temporal graph: A graph whose edges or vertices have time information.

Property graph: A graph with attributes on vertices and/or edges.

Knowledge graph: A typed relational graph representing entities and semantic facts.

Message passing: GNN computation in which vertices aggregate information from neighbors.

Snapshot: A versioned representation of a graph at a defined point or interval.

Graph partitioning: Dividing a graph across processors or machines.

Graph provenance: Information recording the origin and processing history of graph data.

Review Questions

Short Answer Questions

  1. Why is an adjacency matrix usually inappropriate for a very large sparse graph?
  2. What information is stored in the three principal CSR arrays?
  3. Distinguish CSR from CSC in terms of access orientation.
  4. Why is an edge list useful during graph ingestion?
  5. State one privacy risk specific to relationship data.

Long Answer Questions

  1. Compare adjacency matrices, adjacency lists, edge lists, CSR, and CSC with respect to memory, lookup, traversal, updates, and typical applications.
  2. Explain how graph density and degree distribution influence representation selection.
  3. Describe a base-plus-delta architecture for dynamic graphs and discuss its benefits and costs.
  4. Explain how graph representation affects GNN message passing, mini-batch sampling, and GPU execution.
  5. Discuss the correctness, governance, and ethical requirements for a graph-based fraud-detection system.

Analytical / Application Questions

  1. A graph has 2 million vertices and 10 million directed edges. Select a primary representation for repeated outgoing-neighbor traversal and justify the choice. State when you would also maintain a second representation.
  2. Design a representation for a temporal heterogeneous knowledge graph used by a relational GNN. Specify how you would store node types, relation types, timestamps, attributes, and reverse access.
  3. A streaming application requires rapid edge insertion but also performs weekly large-scale PageRank. Propose a multi-representation architecture and explain how updates, compaction, snapshots, and reproducibility would be managed.

Multiple Choice Questions with Answers

Question 1

Which representation provides constant-time access to whether a particular pair of vertices is connected, assuming direct indexing?

A. Adjacency matrix

B. Unsorted adjacency list

C. Edge list

D. COO format before indexing

Correct Answer: A. Adjacency matrix

Question 2

For a sparse graph stored in CSR, what does row_ptr[u+1] − row_ptr[u] represent?

A. The number of vertices in the graph

B. The out-degree of vertex u

C. The weight of edge u

D. The number of connected components

Correct Answer: B. The out-degree of vertex u

Question 3

Which format is most naturally suited to efficient incoming-neighbor access in a directed graph?

A. CSR

B. CSC

C. Unsorted edge list

D. Dense row-major matrix only

Correct Answer: B. CSC

Question 4

What is the standard traversal complexity of BFS using an adjacency list for a graph with n vertices and m edges?

A. O(1)

B. O(n²) in all cases

C. O(n + m)

D. O(m²)

Correct Answer: C. O(n + m)

Question 5

Why is COO commonly useful during graph construction?

A. It requires no vertex identifiers

B. Its parallel coordinate arrays are easy to append and concatenate

C. It guarantees constant-time neighbor queries

D. It stores every possible non-edge explicitly

Correct Answer: B. Its parallel coordinate arrays are easy to append and concatenate

Question 6

Which algorithm is invalid when a reachable edge has a negative weight?

A. Breadth-first search

B. Dijkstra’s algorithm

C. Bellman–Ford

D. Depth-first search

Correct Answer: B. Dijkstra’s algorithm

Question 7

A dense Boolean adjacency matrix for n vertices requires what asymptotic space when stored conventionally?

A. Θ(n)

B. Θ(log n)

C. Θ(n + m) regardless of m

D. Θ(n²)

Correct Answer: D. Θ(n²)

Question 8

In a GNN message-passing layer, the neighborhood aggregation operation is most directly supported by which kind of storage for a large sparse graph?

A. Sparse formats such as CSR or COO

B. A full dense matrix in every minibatch

C. Only a sorted list of vertex names

D. A scalar containing graph density

Correct Answer: A. Sparse formats such as CSR or COO

Question 9

What is a principal disadvantage of arbitrary insertion into a CSR structure?

A. CSR cannot represent directed edges

B. Insertion may require shifting array elements or rebuilding the structure

C. CSR cannot store weights

D. CSR always duplicates every vertex four times

Correct Answer: B. Insertion may require shifting array elements or rebuilding the structure

Question 10

Why should high-stakes graph analytics use versioned snapshots?

A. To guarantee that all graphs become dense

B. To make graph traversal unnecessary

C. To support reproducibility of results and decisions

D. To eliminate the need for access control

Correct Answer: C. To support reproducibility of results and decisions

Advanced Data Structure
Chapter 8 of 15