Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6388847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:19:48+00:00 2026-05-25T03:19:48+00:00

I the discussion of various graph algorithms, I see the terms Path Matrix and

  • 0

I the discussion of various graph algorithms, I see the terms “Path Matrix” and “Transitive Closure” which are not well-defined anywhere.

What does it mean by “Path Matrix” and “Transitive Closure” in case of both Directed and Undirected graphs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:19:49+00:00Added an answer on May 25, 2026 at 3:19 am

    I think unkulunkulu’s answer is pretty complete, but given JMSA seems unsatisfied, I’ll make another attempt.

    Let’s start not with the path matrix, but with the adjacency matrix. The adjacency matrix is the standard representation of a graph. If adj is the adjacency matrix for some graph G, then adj[i][j] == 1 if vertex i is adjacent to vertex j (i.e. there is an edge from i to j), and 0 otherwise. In other words, adj[i][j] == 1 if and only if we can get from vertex i to vertex j in one “step”.

    Now, let’s define another matrix which I’ll call adj2: adj2[i][j] == 1 if and only if we can get from vertex i to vertex j in two steps or less. You might call it a “two-step adjacency” matrix. The important thing is that adj2 can be defined in terms of adj:

    def adj2(i,j):
        if adj(i,j) == 1:
            return 1
        else:
            for k in range(0,n): # where n is the number of vertices in G
                if adj(i,k) == 1 and adj(k,j) == 1:
                    return 1
        return 0
    

    That is, adj2[i][j] is 1 if i is adjacent to j (i.e. adj[i][j] == 1) or if there exists some other vertex k such that you can step from i to k and then from k to j (i.e. adj[i][j] == 1 and adj[k][j] == 1).

    As you can imagine, you can use the same logic to define a “three-step” adjacency matrix adj3, adj4, adj5, and so on. If you go on long enough (e.g. to adjn, where n is the number of vertices in the graph), you get a matrix that tells you whether there’s a path of any length from vertex i to vertex j. This, of course, would also be the graph’s path matrix: adjn[i][j] == path[i][j] for all i, j. (Note: Don’t confuse path matrix with distance matrix.)

    A mathematician would say that path[i][j] is the transitive closure of adj[i][j] on the graph G.

    Transitive closures exist independently from graph theory; adj is not the only thing with a transitive closure. Roughly speaking, all functions (in the programming sense) that take two arguments and return a Boolean value have a transitive closure.

    The equality (==) and inequality (<, >, <=, >=) operators are familiar examples of such functions. These differ from adj, however, in that they are themselves transitive. “f(i,j) is transitive” means that if f(i,j) == true, and f(j,k) == true, then f(i, k) == true. You know that this property is true of, say, the “less than” relation: from a < b and b < c, you can infer that a < c. The transitive closure of a transitive function f is just f.

    adj is not generally transitive. Consider the graph:

    v1---v2---v3
    

    In this graph, adj might represent the function busBetween(city1, city2). Here, there’s a bus you can take from v1 to v2 (adj[1][2] == 1) and a bus from v2 to v3 (adj[2][3] == 1), but there’s no bus from v1 directly to v3 (adj[1][2] == 0). There is a bus-path from v1 to v3, but v1 and v3 are not bus-adjacent. For this graph, adj is not transitive, so path, which is the transitive closure of adj, is different from adj.

    If we add an edge between v1 and v3,

    v1---v2---v3
     \        /
       \----/
    

    then adj becomes transitive: In every possible case, adj[i][j] == 1 and adj[j][k] == 1 implies adj[i][k] == 1. For this graph, path and adj are the same. That the graph is undirected corresponds to the “symmetry” property. If we added loops to each vertex so that v1, v2, and v3 were each adjacent to themselves, the resulting graph would be transitive, symmetric, and “reflexive“, and could be said to represent equality (==) over the set {1,2,3}.

    This begins to illustrate how graphs can represent different functions, and how properties of the function are reflected in properties of the graph. In general, if you let adj represent some function f, then path is the transitive closure of f.

    For a formal definition of transitive closures, I refer you to Wikipedia. It isn’t a hard concept once you understand all the math jargon.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The discussion here describes the display view in eclipse which allows one to to
I recently heard a discussion in which TDD was the hot buzz word. Now
Which of them are preferred in which circumstances? I'd like to see the list
I know there's already discussion of this problem in various places (in and out
Over the last year or so I've seen various announcements on the Clojure discussion
Based on the discussion I found here: Database: To delete or not to delete
In one discussion among colleagues I have heard that function point analysis is not
I've seen several posts on StackOverflow and elsewhere discussing the various ways to bring
The discussion around global variables and their misuse seems to hold a certain dogmatic
A discussion amongst some colleagues emerged recently how in today's software industry, two separate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.