{"componentChunkName":"component---src-templates-blog-post-jsx","path":"/blogs/graph","result":{"data":{"blog":{"frontmatter":{"title":"GRAPH DATA STRUCTURE","thumbnail":"blog44","date":"January 24, 2021","dsaCppCodeFile":null},"excerpt":"<div class=\"my-2 p-2\">\n              <p>\n                In this blog post will study what is a graph data structure,\n                types and applications of graphs.\n              </p>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Definition</h4>\n              <div class=\"m-2\">\n                <p>\n                  A graph is a pair (V, E); where V is a set of nodes, called\n                  vertices and E is a set of pairs of vertices, called edges. A\n                  graph with no cycles is called as tree i.e a tree is an\n                  acyclic connected graph.\n                </p>\n                <p></p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Terminologies</h4>\n              <ul class=\"pl-4\">\n                <li>\n                  <strong>Directed edge: </strong>\n                  Ordered pair of vertices (u,v) where u the edge starts from u\n                  and ends at v. <br />\n                  For ex: One way road.\n                </li>\n                <li>\n                  <strong>Undirected edge: </strong>\n                  Unordered pair of vertices (u,v) where the edge is from u to v\n                  & vice versa. <br />\n                  For ex: Railway lines.\n                </li>\n                <li>\n                  When an edge connects two vertices, the vertices are said to\n                  be adjacent to each other and the edge is incident on both\n                  vertices.\n                </li>\n                <li>\n                  <strong>Self loop: </strong>\n                  An edge that connects a vertex to itself i.e the pair (u,u).\n                </li>\n                <li>\n                  <strong>Degree of a vertex: </strong> The number of edges\n                  incident on a given vertex.\n                </li>\n                <li>\n                  <strong>Subgraph: </strong> A subset of a graph’s edges (with\n                  associated vertices) that form a graph.\n                </li>\n                <li>\n                  <strong>Path: </strong> It is a sequence of adjacent vertices.\n                  Simple path is a path with no repeated vertices.\n                </li>\n                <li>\n                  <strong>Cycle: </strong> A path where the first and last\n                  vertices are the same.\n                </li>\n                <li>\n                  We say that one vertex is connected to another if there is a\n                  path that contains both of them.\n                </li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Types</h4>\n              <ol class=\"pl-4\">\n                <li>\n                  <strong>Directed Graph(Digraph): </strong>\n                  A graph with only directed edges.\n                </li>\n                <li>\n                  <strong>Undirected Graph: </strong> A graph with only\n                  undirected edges.\n                </li>\n                <li>\n                  <strong>Directed Acyclic Graph(DAG or Diagraph): </strong>\n                  A directed graph with no cycles.\n                </li>\n                <li>\n                  <strong>Bipartite Graph: </strong>\n                  A bipartite graph is a graph whose vertices can be divided\n                  into two sets such that all edges connect a vertex in one set\n                  with a vertex in the other set.\n                </li>\n                <li>\n                  <strong>Complete Graph: </strong>\n                  It is a graph with all edges present. A bipartite graph in\n                  which all the edges are present is called as Complete\n                  Bipartite Graph.\n                </li>\n                <li>\n                  <strong>Connected Graph: </strong> A graph is said to be a\n                  connected graph if there is a path from every vertex to every\n                  other vertex. If a graph is not connected then it consists of\n                  a set of connected components.\n                </li>\n              </ol>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Applications</h4>\n              <ul class=\"pl-4\">\n                <li>\n                  Representing relationships between components in electronic\n                  circuits.\n                </li>\n                <li>\n                  Transportation networks: Highway network, Flight network.\n                </li>\n                <li>Computer networks: Local area network, Internet, Web.</li>\n                <li>\n                  Databases: For representing ER (Entity Relationship) diagrams\n                  in databases, for representing dependency of tables in\n                  databases\n                </li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/graphTraversalTechniques\"\n                >Graph Traversal Techniques</a\n              > |\n              <a href=\"/blogs/topologicalSort\">Topological Sort</a>\n            </div>\n","html":"<div class=\"my-2 p-2\">\n              <p>\n                In this blog post will study what is a graph data structure,\n                types and applications of graphs.\n              </p>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Definition</h4>\n              <div class=\"m-2\">\n                <p>\n                  A graph is a pair (V, E); where V is a set of nodes, called\n                  vertices and E is a set of pairs of vertices, called edges. A\n                  graph with no cycles is called as tree i.e a tree is an\n                  acyclic connected graph.\n                </p>\n                <p></p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Terminologies</h4>\n              <ul class=\"pl-4\">\n                <li>\n                  <strong>Directed edge: </strong>\n                  Ordered pair of vertices (u,v) where u the edge starts from u\n                  and ends at v. <br />\n                  For ex: One way road.\n                </li>\n                <li>\n                  <strong>Undirected edge: </strong>\n                  Unordered pair of vertices (u,v) where the edge is from u to v\n                  & vice versa. <br />\n                  For ex: Railway lines.\n                </li>\n                <li>\n                  When an edge connects two vertices, the vertices are said to\n                  be adjacent to each other and the edge is incident on both\n                  vertices.\n                </li>\n                <li>\n                  <strong>Self loop: </strong>\n                  An edge that connects a vertex to itself i.e the pair (u,u).\n                </li>\n                <li>\n                  <strong>Degree of a vertex: </strong> The number of edges\n                  incident on a given vertex.\n                </li>\n                <li>\n                  <strong>Subgraph: </strong> A subset of a graph’s edges (with\n                  associated vertices) that form a graph.\n                </li>\n                <li>\n                  <strong>Path: </strong> It is a sequence of adjacent vertices.\n                  Simple path is a path with no repeated vertices.\n                </li>\n                <li>\n                  <strong>Cycle: </strong> A path where the first and last\n                  vertices are the same.\n                </li>\n                <li>\n                  We say that one vertex is connected to another if there is a\n                  path that contains both of them.\n                </li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Types</h4>\n              <ol class=\"pl-4\">\n                <li>\n                  <strong>Directed Graph(Digraph): </strong>\n                  A graph with only directed edges.\n                </li>\n                <li>\n                  <strong>Undirected Graph: </strong> A graph with only\n                  undirected edges.\n                </li>\n                <li>\n                  <strong>Directed Acyclic Graph(DAG or Diagraph): </strong>\n                  A directed graph with no cycles.\n                </li>\n                <li>\n                  <strong>Bipartite Graph: </strong>\n                  A bipartite graph is a graph whose vertices can be divided\n                  into two sets such that all edges connect a vertex in one set\n                  with a vertex in the other set.\n                </li>\n                <li>\n                  <strong>Complete Graph: </strong>\n                  It is a graph with all edges present. A bipartite graph in\n                  which all the edges are present is called as Complete\n                  Bipartite Graph.\n                </li>\n                <li>\n                  <strong>Connected Graph: </strong> A graph is said to be a\n                  connected graph if there is a path from every vertex to every\n                  other vertex. If a graph is not connected then it consists of\n                  a set of connected components.\n                </li>\n              </ol>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Applications</h4>\n              <ul class=\"pl-4\">\n                <li>\n                  Representing relationships between components in electronic\n                  circuits.\n                </li>\n                <li>\n                  Transportation networks: Highway network, Flight network.\n                </li>\n                <li>Computer networks: Local area network, Internet, Web.</li>\n                <li>\n                  Databases: For representing ER (Entity Relationship) diagrams\n                  in databases, for representing dependency of tables in\n                  databases\n                </li>\n              </ul>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/graphTraversalTechniques\"\n                >Graph Traversal Techniques</a\n              > |\n              <a href=\"/blogs/topologicalSort\">Topological Sort</a>\n            </div>"},"thumbnail":{"childImageSharp":{"fluid":{"tracedSVG":"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='400'%20height='225'%20viewBox='0%200%20400%20225'%20preserveAspectRatio='none'%3e%3cpath%20d='M28%2091c-8%203-7%2019%201%2019%205%200%209-10%203-11-2%200-5%204-3%205v1c-1%202-2%200-2-3%200-4%202-7%203-6v1l2%201c3%200%204-2%203-5-1-2-4-3-7-2m13%200c-4%200-4%200-4%203l-1%2010c0%206%200%206%202%206s3-1%203-3c0-4%201-4%203%200%201%203%201%203%204%202%202-1%202-2%200-4v-5c4-6%201-10-7-9m18%200c-2%200-6%209-7%2016-1%203-1%203%201%203l4-2%203-2%201%202c0%202%201%202%206%202s5%200%205-3c0-2%200-3%202-3%203%200%207-4%207-7%200-4-2-6-6-6-6%200-7%201-8%2010v8l-2-7c-2-11-2-12-6-11m24%204l-1%2010c0%205%200%205%202%205%203%200%203-1%203-4%201-5%204-6%204%200%200%203%200%204%202%204s3-1%203-10c0-10%200-10-2-10s-3%201-3%204l-2%204-1-4c0-3-1-4-3-4-1%200-2%201-2%205m185%207c-3%203-5%2013-3%2017%201%202%204%203%205%201%201-1-1-9-3-10-4-1%202-9%208-9%207%200%209%205%206%2011-2%205-2%208%200%209%204%201%207-8%204-9l-1-4c0-8-10-12-16-6m31%204l-1%208v7h17l-5%205a66%2066%200%2000-19%2037l-2%2010v1l6-7c7-9%2017-15%2017-10%200%202%201%203%203%203s3-1%201-2l-1-3h4c3%200%202%201%200%204l-2%204v3h-17v7c0%206%200%207-2%208-3%202-3%203%200%203%202%200%203%204%201%206l-6%201c-9%200-11-4-7-9l2-5c0-3-8%206-8%2010-1%203-1%203-10%204-8%200-8%200-8%202s1%203%205%203c5%200%206%200%204%205-1%202%201%202%2048%202h49l1-4c1-2%202-3%205-3%205-1%205-4%200-5h-3v-14c0-14-1-21-4-21l-2-2-1-2c-7-1-7-4-3-12%207-13%207-17%200-22-4-3-5-4-5-8l-1-4c-1-1-1%201-1%204%200%205%200%205-2%204l-23%201-3%201v-10l-14-1-13%201m2%208v6h22v-13h-22v7M24%20124l-1%2010v9l3-1c5%200%207-2%208-5%202-4%202-9%200-12-1-2-7-3-10-1m18%202l-4%209-2%207h3l3-1c1-2%205-3%205-1s4%203%205%202l-3-17c-1-3-6-3-7%201m11%200c0%203%200%203%202%203%202-1%202-1%202%206s0%207%203%207c2%200%202%200%202-7%200-6%200-7%203-7l2-3c0-2-1-2-7-2h-7v3m20%200c-2%202-6%2015-6%2016h3l3-1c0-3%204-2%204%200%201%202%204%202%205%201s-2-16-3-18c-2-2-5-1-6%202m21%200c-3%203-3%205%202%209l4%203h-4c-3%200-3%200-3%202%200%203%208%203%2010%200s1-6-2-8l-3-4h1c1%202%205%203%205%201l3-1c2%200%202%200%202%207s0%207%202%207%203-1%203-2c0-11%200-12%202-12l2-3c0-2-1-2-6-2-6%200-7%200-7%202h-2c-3-3-7-2-9%201m27-2l-2%209v9h2c2%200%203-1%203-3l1-3%201%203c2%203%203%203%205%202v-3c-1-3-1-4%201-6v-6c-2-3-8-4-11-2m14%201v15c1%203%208%203%2010%200%203-4%203-17%200-17-2%200-3%203-3%2010%200%204-1%206-3%205v-8c0-6%200-7-2-7l-2%202m16%200c-3%204-4%2011-2%2014%203%204%208%204%2011%200%202-3%200-5-3-2s-5-1-3-7c1-3%204-4%203-1-1%202%200%202%202%202l3-1c0-1%201-2%203-2s2%200%202%207%200%207%203%207l2-1v-7c0-5%200-6%202-6l2-3c0-2-1-2-6-2-7%200-7%200-7%202v2l-2-2c-3-3-7-3-10%200m27%201v15l5%201c5%200%207-3%207-11%200-7%200-8-2-8-1%200-2%201-3%207-1%209-2%209-3%200%200-6%200-7-2-7-1%200-2%201-2%203m15-2l-2%209v9h2c2%200%203-1%203-3l1-3%201%203c2%203%203%203%205%202v-3c-1-2-1-4%201-6%201-3%201-5-1-7-1-2-8-3-10-1m14%201l-1%2010v7h7c6%200%206%200%206-2%200-3%200-3-4-3-5%200-5-2-1-2%204-1%204-5%200-5l-3-1%204-1c3%200%204%200%204-2%201-3%200-3-6-3-5%200-6%200-6%202m63%2016l1%209h12v-18h-13v9m55%2016c0%201-1%202-3%202s-2%201-2%204v3h6c9%200%209%200%208%207l1%208v2l-1%203c0%204%200%204%205%204%207%201%2010-1%207-7v-5l-1-3-3-5-1-3h-1v-2l-3-5c-1-2-3-3-7-4l-5-2v3m-52%207l-1%205c0%203%200%204-1%203%200-4-2-3-3%200l2%204%202%203%203%201c2%200%202%200%202-3%200-2%200-3%202-3s2-1%202-4l-1-4-1%203c0%204-2%203-2-2-1-3-1-4-4-3'%20fill='%23d3d3d3'%20fill-rule='evenodd'/%3e%3c/svg%3e","aspectRatio":1.7699115044247788,"src":"/static/42bd8ba9025c5b207717cb9d48e72c92/ee604/blog44.png","srcSet":"/static/42bd8ba9025c5b207717cb9d48e72c92/69585/blog44.png 200w,\n/static/42bd8ba9025c5b207717cb9d48e72c92/497c6/blog44.png 400w,\n/static/42bd8ba9025c5b207717cb9d48e72c92/ee604/blog44.png 800w,\n/static/42bd8ba9025c5b207717cb9d48e72c92/f3583/blog44.png 1200w,\n/static/42bd8ba9025c5b207717cb9d48e72c92/e4d72/blog44.png 1280w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"pageContext":{"blog":"graph","thumbnail":"thumbnails/blog44.png"}},"staticQueryHashes":["2987289216","63159454"]}