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 8934179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:43:18+00:00 2026-06-15T09:43:18+00:00

I am trying to identify a transitive relationship between two elements .I am coding

  • 0

I am trying to identify a transitive relationship between two elements .I am coding in c.

for eg: a->b is represented by a “1” in adjacency matrix in 1st row 2nd column.

so if a->b and b-> c and c->d

i want to identify if a->d. no need to update the adjacency matrix.

approach i have adopted: check all the 1’s in the row corresponding to a. lets say there is a 1 in second column ie for b. [(a->b)] , now check if b->d if not proceed to check all the 1’s in B’s row and continue till 26th row.

I am not really concerned with the complexity. i am just hoping to implement this.

  • 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-06-15T09:43:20+00:00Added an answer on June 15, 2026 at 9:43 am

    You need to implement a breadth-first search or a depth-first search. Start at a, and stop when you reach d, or when you exhaust all options.

    In your case, the depth-first search is somewhat easier to implement, because “plain” C lacks built-in dynamic queues needed for the breadth-first search.

    If you do not care about the efficiency and you do not mind updating the matrix, implement the Floyd-Warshall algorithm: it is formulated specifically for adjacency matrices, and takes only five lines to implement:

    for (int k = 0 ; k != N ; k++)
        for (int i = 0 ; i != N ; i++)
            for (int j = 0 ; j != N ; j++)
                if (matrix[i][k] && matrix[k][j])
                    matrix[i][j] = 1;
    

    After running this algorithm, the resultant matrix contains the transitive closure of the original one.

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

Sidebar

Related Questions

I am trying to identify a user ID number, to grab a Student row
I am trying to identify the consecutive three-column groups that have >2 instances of
I am trying to identify the duration of something by finding the difference between
I'm trying to identify if this is an IIS issue or a code issue.
I am trying to identify when an action without authorization has been made. Is
I am trying to identify a screen in a multi-monitor setup to save some
I am trying to identify duplicate serial numbers from the following xml using XPath
I am trying to identify file types for directory entries (Windows Unix etc..). In
I am trying to identify all the nodes in a tree that lead to
I am trying to identify SQL INSERTS that occur when a record is viewed

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.