Skip to main content

CT Week 10

Graph Representations

📚

Representation of Graph as Adjacency Matrix

An adjacency matrix is a way to represent a graph using a square matrix. Each cell in the matrix indicates whether a pair of vertices is connected by an edge. For a graph with V vertices, the adjacency matrix A is a V × V matrix where:

  • A[i][j] = 1 if there is an edge between vertex i and vertex j.
  • A[i][j] = 0 if there is no edge between vertex i and vertex j.

This representation is particularly useful for dense graphs where the number of edges is large. For example, consider a graph with 4 vertices:

        0 - 1
        |   |
        2 - 3
    

The adjacency matrix for this graph would be:

        0 1 1 0
        1 0 0 1
        1 0 0 1
        0 1 1 0
    

One-Hop Neighbors

One-hop neighbors of a vertex in a graph are the vertices that are directly connected to it by an edge. In terms of the adjacency matrix, if A[i][j] = 1, then vertex j is a one-hop neighbor of vertex i. This concept is crucial for understanding immediate connections and direct relationships in a network.

For example, in the graph represented above, the one-hop neighbors of vertex 0 are vertices 1 and 2.

Two-Hop Neighbors

Two-hop neighbors of a vertex are the vertices that can be reached by traversing exactly two edges. In the adjacency matrix, this can be determined by squaring the matrix A. If (A^2)[i][j] > 0, then vertex j is a two-hop neighbor of vertex i. This helps in analyzing indirect connections and the extended reach of a vertex within the graph.

For example, in the graph represented above, the two-hop neighbors of vertex 0 are vertices 3.

Comments

Popular post

IITM Notes

Course Overview “These handwritten notes encompass topics in data science and civil services. The beauty of knowledge is that you don’t need to belong to any specific group; simply maintain your curiosity, and knowledge will find its way to you. I hope these notes are helpful. If they are, please consider leaving a comment below and follow my blog for updates.” Mathematics 1 👉 Select Week Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Week 8 Week 9 Week 10 Week 11 Revision Statistics 1 👉 Select Week Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Week 8 Week 9 Week 10 Week 11

Maths 1 week 1 Summary

Number System and Set Theory 📚 Number System and Set Theory This week, our teacher covered the basics of the number system. We were instructed to consider 0 as part of the natural numbers, as it will be treated as such in future subjects like Python. However, in exams, it will be explicitly stated whether 0 should be considered a natural number. The key topics from this week include set theory and the relationship between two sets. In set theory, we focused on three Venn diagram problems. In the context of relations, we discussed the concepts of reflexive, symmetric, transitive, and equivalence relations. Detailed Explanation 1.Union of Two Sets The union of two sets A and B is the set of elements that are in either A , B , or both. It is denoted as A ∪ B . 2.Intersection of Two Sets The intersection of two sets A and B is the set of elements that are in both A and B . It is denoted as A ∩ B . 3.Subt

Community page

Welcome To our IITM BS Students Community This community is a student commune where IIT Madras Bachelor of Science students are studying. Our community is managed by 15 community admins who oversee our WhatsApp community, Discord, and Telegram profiles. With more than 1000+ active members, we study together, share memes, watch movies, play games, and have fun. Our goal is to bring all online IITM students together to excel in exams while having fun. Community Admins Agampreet LinkedIn Ansh Ashwin Ambatwar Arti Dattu Dolly Elango Koushik Shrijanani Saksham Shivamani Shivam Instagram LinkedIn Join Our Community Subscribe to our YouTube page Join our meme team on