Matrix Algebra in Social Networks: Part II

Multiplication, Conformability, and Applications (Paths & Walks)

Part 1: Conformability Rules

Standard Matrix Multiplication (\(\mathbf{A} \times \mathbf{B}\))

  • Unlike the element-wise Hadamard product, standard matrix multiplication is non-elementary.
  • It involves multiplying the rows of the left matrix by the columns of the right matrix.
  • Because rows and columns are matched, the sizes of the two multiplier matrices must follow a strict structural rule.
  • This rule is called Conformability.

The Conformability Rule

  • You can only multiply two matrices if the number of columns of the first matrix equals the number of rows of the second matrix.
  • Put their dimensions side-by-side:

\[\mathbf{A}_{3 \times \mathbf{5}} \times \mathbf{B}_{\mathbf{5} \times 6}\]

  • Inner Dimensions: The bold “fives” are the inner dimensions. They must be identical for the multiplication to be defined (conformable).
  • Outer Dimensions: The “three” and “six” are the outer dimensions. They dictate the size of the resulting product matrix:

\[\mathbf{A}_{3 \times \mathbf{5}} \times \mathbf{B}_{\mathbf{5} \times 6} = \mathbf{C}_{3 \times 6}\]

Clarification: Why Conformability Matters

When we compute cell \(c_{ij}\) in the product matrix, we: 1. Take Row \(i\) of the left matrix (which has as many elements as the left matrix has columns). 2. Take Column \(j\) of the right matrix (which has as many elements as the right matrix has rows). 3. Multiply element-by-element and sum.

For this to work, the row length and column length must match!

Example: - Row from \(\mathbf{A}\): 5 numbers - Column from \(\mathbf{B}\): 5 numbers - ✓ Can match them up and multiply.

If Column from \(\mathbf{B}\) had 7 numbers, we’d have a mismatch and can’t compute the sum.

Conformable vs. Non-Conformable

Conformable Example

  • Line up dimensions: \[\mathbf{A}_{4 \times \mathbf{2}} \times \mathbf{B}_{\mathbf{2} \times 3}\]
  • Inner dimensions match (2 = 2).
  • The multiplication is fully defined.
  • Product Matrix size: \[\mathbf{C}_{4 \times 3}\]

Non-Conformable Example

  • Line up dimensions: \[\mathbf{A}_{3 \times \mathbf{4}} \times \mathbf{B}_{\mathbf{2} \times 3}\]
  • Inner dimensions clash (4 \(\neq\) 2).
  • This operation is mathematically impossible.
  • The Visual Reason: When you try to dot-multiply a row of 4 by a column of 2, you “run out of numbers” on the right, making the sum undefined.

Matrix Multiplication is Non-Commutative

  • In scalar math, order doesn’t matter: \(4 \times 3 = 3 \times 4\).
  • In matrix algebra, order completely changes the structure:

\[\mathbf{A}_{2 \times \mathbf{3}} \times \mathbf{B}_{\mathbf{3} \times 2} = \mathbf{C}_{2 \times 2} \quad \text{(Square 2x2 Matrix)}\]

\[\mathbf{B}_{3 \times \mathbf{2}} \times \mathbf{A}_{\mathbf{2} \times 3} = \mathbf{D}_{3 \times 3} \quad \text{(Square 3x3 Matrix)}\]

  • Changing the multiplication order changes both the conformability checks and the resulting network’s dimensions!

Clarification: Non-Commutativity in Networks

Why does order matter socially?

  • \(\mathbf{A} \times \mathbf{B}\): “How many paths are there from ego to alter via intermediate nodes (using \(\mathbf{B}\)’s ties)?”
  • \(\mathbf{B} \times \mathbf{A}\): “How many paths via \(\mathbf{A}\)’s ties?” Different question, different answer, different matrix size.

This mirrors how network directionality and mediation structure change under different relationship sequences.

Part 2: Step-by-Step Multiplication Mechanics

Row-by-Column Vector Multiplication

  • Let’s multiply a \(2 \times 3\) matrix \(\mathbf{A}\) by a \(3 \times 2\) matrix \(\mathbf{B}\) to produce a \(2 \times 2\) matrix \(\mathbf{C}\):

\[\mathbf{A} = \begin{pmatrix} \mathbf{3} & \mathbf{4} & \mathbf{5} \\ 7 & 6 & 3 \end{pmatrix} \quad \mathbf{B} = \begin{pmatrix} \mathbf{3} & 7 \\ \mathbf{4} & 9 \\ \mathbf{5} & 3 \end{pmatrix}\]

  • To compute cell \(c_{ij}\) in the target matrix, we multiply row \(i\) of the left matrix by column \(j\) of the right matrix, then sum the products.
  • Let’s trace each of the 4 cells in the target matrix \(\mathbf{C}_{2 \times 2}\) progressively.

Target Cell \(c_{11}\) (Row 1, Column 1)

  • Red = Row 1 of \(\mathbf{A}\) — Blue = Column 1 of \(\mathbf{B}\)

\[\mathbf{A} = \begin{pmatrix} \color{red}{\mathbf{3}} & \color{red}{\mathbf{4}} & \color{red}{\mathbf{5}} \\ 7 & 6 & 3 \end{pmatrix}\]

\[\mathbf{B} = \begin{pmatrix} \color{blue}{\mathbf{3}} & 7 \\ \color{blue}{\mathbf{4}} & 9 \\ \color{blue}{\mathbf{5}} & 3 \end{pmatrix}\]

Target Matrix C (Building)

\[\mathbf{C} = \begin{pmatrix} \mathbf{50} & ? \\ ? & ? \end{pmatrix}\]

\[c_{11} = (\color{red}{3} \times \color{blue}{3}) + (\color{red}{4} \times \color{blue}{4}) + (\color{red}{5} \times \color{blue}{5}) = 9 + 16 + 25 = \mathbf{50}\]

Target Cell \(c_{12}\) (Row 1, Column 2)

  • Red = Row 1 of \(\mathbf{A}\) — Blue = Column 2 of \(\mathbf{B}\)

\[\mathbf{A} = \begin{pmatrix} \color{red}{\mathbf{3}} & \color{red}{\mathbf{4}} & \color{red}{\mathbf{5}} \\ 7 & 6 & 3 \end{pmatrix}\]

\[\mathbf{B} = \begin{pmatrix} 3 & \color{blue}{\mathbf{7}} \\ 4 & \color{blue}{\mathbf{9}} \\ 5 & \color{blue}{\mathbf{3}} \end{pmatrix}\]

Target Matrix C (Building)

\[\mathbf{C} = \begin{pmatrix} 50 & \mathbf{72} \\ ? & ? \end{pmatrix}\]

\[c_{12} = (\color{red}{3} \times \color{blue}{7}) + (\color{red}{4} \times \color{blue}{9}) + (\color{red}{5} \times \color{blue}{3}) = 21 + 36 + 15 = \mathbf{72}\]

Target Cell \(c_{21}\) (Row 2, Column 1)

  • Red = Row 2 of \(\mathbf{A}\) — Blue = Column 1 of \(\mathbf{B}\)

\[\mathbf{A} = \begin{pmatrix} 3 & 4 & 5 \\ \color{red}{\mathbf{7}} & \color{red}{\mathbf{6}} & \color{red}{\mathbf{3}} \end{pmatrix}\]

\[\mathbf{B} = \begin{pmatrix} \color{blue}{\mathbf{3}} & 7 \\ \color{blue}{\mathbf{4}} & 9 \\ \color{blue}{\mathbf{5}} & 3 \end{pmatrix}\]

Target Matrix C (Building)

\[\mathbf{C} = \begin{pmatrix} 50 & 72 \\ \mathbf{60} & ? \end{pmatrix}\]

\[c_{21} = (\color{red}{7} \times \color{blue}{3}) + (\color{red}{6} \times \color{blue}{4}) + (\color{red}{3} \times \color{blue}{5}) = 21 + 24 + 15 = \mathbf{60}\]

Target Cell \(c_{22}\) (Row 2, Column 2)

  • Red = Row 2 of \(\mathbf{A}\) — Blue = Column 2 of \(\mathbf{B}\)

\[\mathbf{A} = \begin{pmatrix} 3 & 4 & 5 \\ \color{red}{\mathbf{7}} & \color{red}{\mathbf{6}} & \color{red}{\mathbf{3}} \end{pmatrix}\]

\[\mathbf{B} = \begin{pmatrix} 3 & \color{blue}{\mathbf{7}} \\ 4 & \color{blue}{\mathbf{9}} \\ 5 & \color{blue}{\mathbf{3}} \end{pmatrix}\]

Finished Target Matrix C

\[\mathbf{C} = \begin{pmatrix} 50 & 72 \\ 60 & \mathbf{112} \end{pmatrix}\]

\[c_{22} = (\color{red}{7} \times \color{blue}{7}) + (\color{red}{6} \times \color{blue}{9}) + (\color{red}{3} \times \color{blue}{3}) = 49 + 54 + 9 = \mathbf{112}\]

Conceptual Bridge: What Does Multiplication Mean in Networks?

Before diving into applications, step back:

  • In matrix multiplication, each cell \(c_{ij}\) of the product counts paths of a specific type connecting \(i\) to \(j\) through intermediate nodes.
  • The row-by-column multiplication is not arbitrary—it’s counting how many intermediate nodes \(k\) satisfy the path condition.
  • In network terms: “For each person \(k\) they both connect to, add 1 to their path count.”

This is the foundation for all dynamic network applications: common neighbors, clustering, walks, reachability.

Part 3: Dynamic Network Applications

Transpose Multiplication: Finding Common Neighbors

  • If we multiply a network’s adjacency matrix \(\mathbf{P}\) by its transpose \(\mathbf{P}^T\):

\[\mathbf{P} \times \mathbf{P}^T = \mathbf{C}_{\text{common}}\]

  • The rows of \(\mathbf{P}\) list each node’s friends; the columns of \(\mathbf{P}^T\) list them a second time
  • So each cell \(c_{ij}\) multiplies node \(i\)’s friendship list by node \(j\)’s — the result counts how much the two lists overlap: their common neighbors!

  • Our running example: six friends (A–F) and their “parties with” ties

Why Does \(\mathbf{P} \times \mathbf{P}^T\) Find Common Neighbors?

  • The Diagonal Cells (\(c_{ii}\)):
    • Multiplies Row \(i\) by Column \(i\) (which is Row \(i\) again in a symmetric matrix).
    • Result: \(\sum_k p_{ik} \times p_{ik} = \sum_k p_{ik}^2\). Since \(p_{ik} \in \{0,1\}\), this becomes \(\sum_k p_{ik}\) = the degree of node \(i\) (total friends).
  • The Off-Diagonal Cells (\(c_{ij}\)):
    • Multiplies Row \(i\) (node \(i\)’s friendships) by Column \(j\) of \(\mathbf{P}^T\) (which is Row \(j\), node \(j\)’s friendships).
    • Result: Counts exactly how many common neighbors node \(i\) and node \(j\) share (mutual friends).

Transpose Multiplication (\(\mathbf{P} \times \mathbf{P}^T\)): Setup

\(\mathbf{P}\) (the adjacency matrix)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

\(\mathbf{P}^T\) (columns of \(\mathbf{P}^T\) = rows of \(\mathbf{P}\))

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0
  • Our \(6 \times 6\) “parties with” matrix \(\mathbf{P}\) is symmetric, so \(\mathbf{P}^T\) contains the same numbers — but read its entries by column: column \(j\) of \(\mathbf{P}^T\) is node \(j\)’s friendship row
  • Multiplying \(\mathbf{P} \times \mathbf{P}^T\) therefore compares every node’s friendship row with every other node’s friendship row

Transpose Multiplication (\(\mathbf{P} \times \mathbf{P}^T\)): Diagonal Cells (Degrees)

Row 3 of \(\mathbf{P}\) (C’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

Column 3 of \(\mathbf{P}^T\) (= Row 3 of \(\mathbf{P}\))

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

\[c_{33} = (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) = \mathbf{5}\]

  • The diagonal recovers the degree sequence: \(c_{33} = 5\).

Transpose Multiplication: Another Diagonal Cell (\(p^T_{\text{E, E}}\))

Row 5 of \(\mathbf{P}\) (E’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

Column 5 of \(\mathbf{P}^T\) (= Row 5 of \(\mathbf{P}\))

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

\[c_{55} = (\color{red}{1} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{1}) = \mathbf{4}\]

  • Node E has degree 4 (friends: A, C, D, F). The diagonal element \(c_{55} = 4\) is E’s degree.

Transpose Multiplication (\(\mathbf{P} \times \mathbf{P}^T\)): Off-Diagonal Cells (Common Neighbors)

Row 1 of \(\mathbf{P}\) (A’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

Column 3 of \(\mathbf{P}^T\) (C’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

\[c_{\text{A, C}} = (\color{red}{0} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{0}) + (\color{red}{0} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{1}) = \mathbf{2}\]

  • In the graph: red A, blue C, green shared friends. Each shared friend contributes \(\mathbf{1}\) (the bold pairs) — A and C share 2 common friends: B and E

Transpose Multiplication: Another Off-Diagonal Cell (\(p^T_{\text{B, E}}\))

Row 2 of \(\mathbf{P}\) (B’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

Column 5 of \(\mathbf{P}^T\) (E’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

\[c_{\text{B, E}} = (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{0} \times \color{blue}{1}) = \mathbf{3}\]

  • Red B and blue E share 3 common friends: A, C, D.

The Completed Product Matrix

A B C D E F
A 3 1 2 3 1 2
B 1 3 2 1 3 1
C 2 2 5 2 3 1
D 3 1 2 3 1 2
E 1 3 3 1 4 1
F 2 1 1 2 1 2

  • Diagonal (shaded): degree of each node
  • Off-diagonal: common friends between pairs
  • Symmetric: friendship overlap is mutual

Application: Common Neighbors & Clustering

Why does this matter?

  • High common neighbors → likely future tie formation (Granovetter’s homophily).
  • Low common neighbors → structural hole (Burt’s brokerage).
  • Network clustering emerges from diagonal sums: nodes with many common neighbors form dense cliques.

The Directed Case: Out-Neighbors vs. In-Neighbors

  • Our running example \(\mathbf{P}\) is symmetric, so \(\mathbf{P} \times \mathbf{P}^T\) and \(\mathbf{P}^T \times \mathbf{P}\) are the same computation.
  • For a directed graph, rows and columns carry different information:
    • Row \(i\) of \(\mathbf{D}\) = node \(i\)’s out-ties (whom \(i\) chose)
    • Column \(j\) of \(\mathbf{D}\) = who chose \(j\) — \(j\)’s in-ties
  • So the two multiplication orders now answer different questions:
  • \(\mathbf{D} \times \mathbf{D}^T\): multiplies rows of \(\mathbf{D}\) by rows of \(\mathbf{D}\) (via \(\mathbf{D}^T\)) → counts nodes both \(i\) and \(j\) chose: their common out-neighbors
  • \(\mathbf{D}^T \times \mathbf{D}\): multiplies columns of \(\mathbf{D}\) by columns of \(\mathbf{D}\) (via \(\mathbf{D}^T\)) → counts nodes that chose both \(i\) and \(j\): their common in-neighbors
  • Both products are symmetric even though \(\mathbf{D}\) is not — overlap is mutual
  • Diagonals differ: \(\mathbf{D}\mathbf{D}^T\) recovers the out-degrees; \(\mathbf{D}^T\mathbf{D}\) recovers the in-degrees

Directed Running Example: “Sends a Party Invitation To”

\(\mathbf{D}\) (the directed adjacency matrix)

A B C D E
A 0 1 1 1 0
B 0 0 1 1 0
C 0 0 0 1 0
D 0 0 0 0 1
E 1 0 1 0 0

\(\mathbf{D}^T\) (rows of \(\mathbf{D}^T\) = columns of \(\mathbf{D}\))

A B C D E
A 0 0 0 0 1
B 1 0 0 0 0
C 1 1 0 0 1
D 1 1 1 0 0
E 0 0 0 1 0
  • New running example: five people (A–E); a tie \(i \rightarrow j\) means \(i\) invited \(j\)
  • \(\mathbf{D}\) is not symmetric — choosing is not the same as being chosen — so \(\mathbf{D}^T\) is a genuinely different matrix
  • Read \(\mathbf{D}\) by rows (out-ties: A invites B, C, D) and by columns (in-ties: C is invited by A, B, E)

Common Out-Neighbors (\(\mathbf{D} \times \mathbf{D}^T\)): Tracing the Diagonal Cell \((\mathbf{D}\mathbf{D}^T)_{\text{A, A}}\)

Row A of \(\mathbf{D}\) (A’s out-ties)

A B C D E
A 0 1 1 1 0
B 0 0 1 1 0
C 0 0 0 1 0
D 0 0 0 0 1
E 1 0 1 0 0

Column A of \(\mathbf{D}^T\) (= Row A of \(\mathbf{D}\))

A B C D E
A 0 0 0 0 1
B 1 0 0 0 0
C 1 1 0 0 1
D 1 1 1 0 0
E 0 0 0 1 0

\[c_{\text{A, A}} = (\color{red}{0} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{0}) = \mathbf{3}\]

  • A pairs with itself: every out-tie matches itself, so \(c_{\text{A, A}} = 3\) = A’s out-degree

Common Out-Neighbors (\(\mathbf{D} \times \mathbf{D}^T\)): Tracing Cell \((\mathbf{D}\mathbf{D}^T)_{\text{A, B}}\)

Row A of \(\mathbf{D}\) (A’s out-ties)

A B C D E
A 0 1 1 1 0
B 0 0 1 1 0
C 0 0 0 1 0
D 0 0 0 0 1
E 1 0 1 0 0

Column B of \(\mathbf{D}^T\) (= Row B of \(\mathbf{D}\))

A B C D E
A 0 0 0 0 1
B 1 0 0 0 0
C 1 1 0 0 1
D 1 1 1 0 0
E 0 0 0 1 0

\[c_{\text{A, B}} = (\color{red}{0} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{0}) = \mathbf{2}\]

  • Red A and blue B invited the same two people: C and D — 2 common out-neighbors

Common Out-Neighbors (\(\mathbf{D} \times \mathbf{D}^T\)): Tracing Cell \((\mathbf{D}\mathbf{D}^T)_{\text{C, D}}\)

Row C of \(\mathbf{D}\) (C’s out-ties)

A B C D E
A 0 1 1 1 0
B 0 0 1 1 0
C 0 0 0 1 0
D 0 0 0 0 1
E 1 0 1 0 0

Column D of \(\mathbf{D}^T\) (= Row D of \(\mathbf{D}\))

A B C D E
A 0 0 0 0 1
B 1 0 0 0 0
C 1 1 0 0 1
D 1 1 1 0 0
E 0 0 0 1 0

\[c_{\text{C, D}} = (\color{red}{0} \times \color{blue}{0}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{0}) + (\color{red}{0} \times \color{blue}{1}) = \mathbf{0}\]

  • Red C invites only D; blue D invites only E — nothing in green: 0 common out-neighbors

The Completed \(\mathbf{D} \times \mathbf{D}^T\) Matrix

A B C D E
A 3 2 1 0 1
B 2 2 1 0 1
C 1 1 1 0 0
D 0 0 0 1 0
E 1 1 0 0 2

  • Diagonal (shaded): the out-degrees
  • Off-diagonal: how many people two nodes both invited
  • Symmetric — even though \(\mathbf{D}\) itself is not

Common In-Neighbors (\(\mathbf{D}^T \times \mathbf{D}\)): Tracing the Diagonal Cell \((\mathbf{D}^T\mathbf{D})_{\text{C, C}}\)

Row C of \(\mathbf{D}^T\) (who invited C)

A B C D E
A 0 0 0 0 1
B 1 0 0 0 0
C 1 1 0 0 1
D 1 1 1 0 0
E 0 0 0 1 0

Column C of \(\mathbf{D}\) (who invited C)

A B C D E
A 0 1 1 1 0
B 0 0 1 1 0
C 0 0 0 1 0
D 0 0 0 0 1
E 1 0 1 0 0

\[c_{\text{C, C}} = (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{1}) = \mathbf{3}\]

  • C pairs with itself: every in-tie matches itself, so \(c_{\text{C, C}} = 3\) = C’s in-degree (A, B, and E invited C)

Common In-Neighbors (\(\mathbf{D}^T \times \mathbf{D}\)): Tracing Cell \((\mathbf{D}^T\mathbf{D})_{\text{C, D}}\)

Row C of \(\mathbf{D}^T\) (who invited C)

A B C D E
A 0 0 0 0 1
B 1 0 0 0 0
C 1 1 0 0 1
D 1 1 1 0 0
E 0 0 0 1 0

Column D of \(\mathbf{D}\) (who invited D)

A B C D E
A 0 1 1 1 0
B 0 0 1 1 0
C 0 0 0 1 0
D 0 0 0 0 1
E 1 0 1 0 0

\[c_{\text{C, D}} = (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{0}) = \mathbf{2}\]

  • Rows of \(\mathbf{D}^T\) are \(\mathbf{D}\)’s columns: in-tie lists. Red C and blue D were invited by the same two people: A and B — 2 common in-neighbors

Common In-Neighbors (\(\mathbf{D}^T \times \mathbf{D}\)): Tracing Cell \((\mathbf{D}^T\mathbf{D})_{\text{A, B}}\)

Row A of \(\mathbf{D}^T\) (who invited A)

A B C D E
A 0 0 0 0 1
B 1 0 0 0 0
C 1 1 0 0 1
D 1 1 1 0 0
E 0 0 0 1 0

Column B of \(\mathbf{D}\) (who invited B)

A B C D E
A 0 1 1 1 0
B 0 0 1 1 0
C 0 0 0 1 0
D 0 0 0 0 1
E 1 0 1 0 0

\[c_{\text{A, B}} = (\color{red}{0} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{0}) = \mathbf{0}\]

  • Only E invites A and only A invites B — nobody invites both: 0 common in-neighbors

The Completed \(\mathbf{D}^T \times \mathbf{D}\) Matrix

A B C D E
A 1 0 1 0 0
B 0 1 1 1 0
C 1 1 3 2 0
D 0 1 2 3 0
E 0 0 0 0 1

  • Diagonal (shaded): the in-degrees
  • Off-diagonal: how many senders two nodes share
  • The payoff: A and B share 2 out-neighbors but 0 in-neighbors; C and D are the mirror image

Application: Reading the Two Directed Products

Why the difference matters:

  • \(\mathbf{D} \times \mathbf{D}^T\) (common out-neighbors): two nodes with the same taste — they choose the same people. In citation networks: bibliographic coupling (two papers citing the same references).
  • \(\mathbf{D}^T \times \mathbf{D}\) (common in-neighbors): two nodes chosen by the same people — shared appeal. In citation networks: co-citation (two papers cited by the same papers).
  • A and B invite the same crowd but nobody invites both of them: high out-overlap, zero in-overlap.
  • C and D are invited by the same crowd but invite nobody in common: the mirror image.

Matrix Powers (\(\mathbf{P}^n\)) & Walks in Networks

  • Multiplying a square adjacency matrix by itself recursively reveals indirect connections (walks):
    • \(\mathbf{P}^2 = \mathbf{P} \times \mathbf{P}\)
    • \(\mathbf{P}^3 = \mathbf{P} \times \mathbf{P} \times \mathbf{P}\)
  • In network science, the entries of the \(n^{\text{th}}\) power of an adjacency matrix have a precise graph-theoretic meaning:
    • Off-Diagonal Cells (\(p^{n}_{ij}\)): Record the exact number of walks of length \(n\) connecting node \(i\) and node \(j\).
    • Diagonal Cells (\(p^{n}_{ii}\)): Record the exact number of closed walks (cycles) of length \(n\) starting and ending at node \(i\).

Clarification: Walks vs. Paths

  • Walk: A sequence of edges, allowing repetition of nodes and edges. Example: A→B→A→C (node A visited twice).
  • Path: A walk with no repeated nodes. Example: A→B→C (each node visited once).
  • Matrix powers count walks, not geodesic (shortest) paths.

For networks, walks reveal all indirect connections, not just optimal routes—important for diffusion, information flow, and redundancy.

Walks of Length 2 (\(\mathbf{P}^2\)): Setup & Intuition

  • To find walks of length 2, we square the adjacency matrix:

\[\mathbf{P}^2 = \mathbf{P} \times \mathbf{P}\]

  • Since \(\mathbf{P}\) is undirected, \(\mathbf{P}^T = \mathbf{P}\), making \(\mathbf{P}^2\) identical to \(\mathbf{P} \times \mathbf{P}^T\).
  • Therefore, walks of length 2 are mathematically equivalent to common neighbors!
  • Why? To go from \(i \rightarrow k \rightarrow j\) (walk of length 2), node \(k\) must be a common friend connected to both \(i\) and \(j\).

Walks of Length 2 (\(\mathbf{P}^2\)): Tracing Cell \(p^2_{\text{A, C}}\)

Row 1 of \(\mathbf{P}\) (A’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

Column 3 of \(\mathbf{P}\) (C’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

\[p^2_{\text{A, C}} = (\color{red}{0} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{0}) + (\color{red}{0} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{1}) = \mathbf{2}\]

  • In the graph: red A, blue C, green shared friends. The two walks are \(A \rightarrow \mathbf{B} \rightarrow C\) and \(A \rightarrow \mathbf{E} \rightarrow C\) — exactly the 2 common friends we found for \(c_{\text{A, C}}\) earlier!

Walks of Length 2 (\(\mathbf{P}^2\)): Tracing Diagonal Cell \(p^2_{\text{C, C}}\)

Row 3 of \(\mathbf{P}\) (C’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

Column 3 of \(\mathbf{P}\) (also C’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

\[p^2_{\text{C, C}} = (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{0} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) = \mathbf{5}\]

  • Walks from C back to C are round trips to each friend (\(C \rightarrow A \rightarrow C\), etc.) — the diagonal of \(\mathbf{P}^2\) recovers the degrees, same as \(\mathbf{P} \times \mathbf{P}^T\)!

Application: Walks and Reachability

Why count walks?

  • Short walks (length 2–3) reveal local clustering and potential tie formation.
  • Longer walks identify reachable components and information-flow paths.
  • Comparing \(\mathbf{P}^n\) for different \(n\) shows how networks “thicken” or “thin” with distance.

Walks of Length 3 (\(\mathbf{P}^3\)) & Triangle Counting

  • To find walks of length 3, we multiply the squared matrix \(\mathbf{P}^2\) by the original matrix:

\[\mathbf{P}^3 = \mathbf{P}^2 \times \mathbf{P}\]

  • Diagonal cells (\(p^3_{ii}\)): Count length-3 cycles — triangles — starting and ending at node \(i\).
  • Since each triangle can be walked in two directions (clockwise & counterclockwise), the number of triangles node \(i\) belongs to is: \[\text{Triangles}(i) = \frac{p^3_{ii}}{2}\]

Walks of Length 3 (\(\mathbf{P}^3\)): Tracing Cell \(p^3_{\text{A, D}}\)

Row 1 of \(\mathbf{P}^2\) (A’s length-2 walks)

A B C D E F
A 3 1 2 3 1 2
B 1 3 2 1 3 1
C 2 2 5 2 3 1
D 3 1 2 3 1 2
E 1 3 3 1 4 1
F 2 1 1 2 1 2

Column 4 of \(\mathbf{P}\) (D’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

\[p^3_{\text{A, D}} = (\color{red}{3} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{2} \times \color{blue}{1}) + (\color{red}{3} \times \color{blue}{0}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{2} \times \color{blue}{0}) = \mathbf{4}\]

  • A and D are not adjacent but share friends B, C, E — and all 4 walks stay in that cluster: \(A \rightarrow B \rightarrow C \rightarrow D\), \(A \rightarrow C \rightarrow B \rightarrow D\), \(A \rightarrow C \rightarrow E \rightarrow D\), \(A \rightarrow E \rightarrow C \rightarrow D\).

Walks of Length 3 (\(\mathbf{P}^3\)): An Adjacent Pair, \(p^3_{\text{A, C}}\)

Row 1 of \(\mathbf{P}^2\) (A’s length-2 walks)

A B C D E F
A 3 1 2 3 1 2
B 1 3 2 1 3 1
C 2 2 5 2 3 1
D 3 1 2 3 1 2
E 1 3 3 1 4 1
F 2 1 1 2 1 2

Column 3 of \(\mathbf{P}\) (C’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

\[p^3_{\text{A, C}} = (\color{red}{3} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{2} \times \color{blue}{0}) + (\color{red}{3} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) + (\color{red}{2} \times \color{blue}{1}) = \mathbf{10}\]

  • A and C are adjacent, so the 10 walks include backtracking like \(A \rightarrow B \rightarrow A \rightarrow C\) — off-diagonal \(\mathbf{P}^3\) counts every walk, not just sensible paths.

Walks of Length 3 (\(\mathbf{P}^3\)): Tracing Diagonal Cell \(p^3_{\text{C, C}}\)

Row 3 of \(\mathbf{P}^2\) (C’s length-2 walks)

A B C D E F
A 3 1 2 3 1 2
B 1 3 2 1 3 1
C 2 2 5 2 3 1
D 3 1 2 3 1 2
E 1 3 3 1 4 1
F 2 1 1 2 1 2

Column 3 of \(\mathbf{P}\) (C’s friendships)

A B C D E F
A 0 1 1 0 1 0
B 1 0 1 1 0 0
C 1 1 0 1 1 1
D 0 1 1 0 1 0
E 1 0 1 1 0 1
F 0 0 1 0 1 0

\[p^3_{\text{C, C}} = (\color{red}{2} \times \color{blue}{1}) + (\color{red}{2} \times \color{blue}{1}) + (\color{red}{5} \times \color{blue}{0}) + (\color{red}{2} \times \color{blue}{1}) + (\color{red}{3} \times \color{blue}{1}) + (\color{red}{1} \times \color{blue}{1}) = \mathbf{10}\]

  • Node C belongs to 5 triangles: \(\text{Triangles}(C) = p^3_{\text{C, C}}/2 = 10/2\) — each triangle counts twice (once per direction).

Application: Transitivity & Clustering Coefficient

Why count triangles?

  • High triangle count → cohesive, clustered network (friends of friends are friends).
  • Low triangle count → sparse structure (bridging, structural holes).
  • Clustering Coefficient = \(\frac{\text{triangles}(i)}{\text{possible triangles at } i}\) measures node’s embeddedness in cliques.

Summary: Matrix Multiplication in Networks

  • The running example: six friends and their “parties with” ties

One worked example, five operations:

Operation What_it_reveals
P + G Multiplex ties: connected in both networks
Pᵀ (transpose) Reversed tie direction; feeds the dyad census
P × Pᵀ Common neighbors (off-diagonal); degrees (diagonal)
P² = P × P Number of walks of length 2 (= common neighbors)
P³ = P² × P Walks of length 3; diagonal ÷ 2 = triangles
D × Dᵀ, Dᵀ × D (directed) Common out-neighbors vs. common in-neighbors; diagonals = out- / in-degrees

Conclusion & Next Steps

You’ve mastered

  • Matrix arithmetic (addition, complement, Hadamard) and the dyad census.
  • Conformability and the row-by-column mechanics of multiplication.
  • The dynamic readings: common neighbors, walks, triangles.
  • The directed pair: common out-neighbors (\(\mathbf{D}\mathbf{D}^T\)) vs. common in-neighbors (\(\mathbf{D}^T\mathbf{D}\)).

Where it matters

  • Tie prediction: common neighbors forecast friendship formation.
  • Brokerage: few triangles around a tie = a structural hole.
  • Cohesion: high triangle counts mark dense local crowds.

Next up: Centrality — using these same matrices to measure who matters most in the network.