#include\x20\n#include\x20\n\nusing\x20namespace\x20std;\n\nstruct\x20Edge\x20{\n\x20\x20int\x20to;\n\x20\x20int\x20next;\n};\n\nclass\x20Graph\x20{\npublic:\n\x20\x20Graph(int\x20n)\x20:\x20numVertices(n),\x20numEdges(0)\x20{\n\x20\x20\x20head.resize(numVertices, -1);\n\x20\x20}\n\n\x20\x20void\x20addEdge(int\x20from, int\x20to)\x20{\n\x20\x20\x20edges.push_back({to, head[from]});\n\x20\x20\x20head[from] = numEdges++;\n\x20\x20}\n\n\x20\x20void\x20printGraph()\x20{\n\x20\x20\x20for\x20(int\x20i\x20=\x200; i\x20<\x20numVertices; i++)\x20{\n\x20\x20\x20\x20cout\x20<<\x20"Adjacency\x20list\x20of\x20vertex\x20"\x20<<\x20i\x20<<\x20":\x20";\n\x20\x20\x20\x20int\x20edgeIndex\x20=\x20head[i];\n\x20\x20\x20\x20while\x20(edgeIndex\x20!=\x20-1)\x20{\n\x20\x20\x20\x20\x20cout\x20<<\x20edges[edgeIndex].to\x20<<\x20"\x20";\n\x20\x20\x20\x20\x20edgeIndex\x20=\x20edges[edgeIndex].next;\n\x20\x20\x20\x20}\n\x20\x20\x20\x20cout\x20<<\x20endl;\n\x20\x20\x20}\n\x20\x20}\n\nprivate:\n\x20\x20int\x20numVertices;\n\x20\x20int\x20numEdges;\n\x20\x20vector\x20head;\n\x20\x20vector\x20edges;\n};\n\nint\x20main()\x20{\n\x20\x20Graph\x20g(5);\n\x20\x20g.addEdge(0, 1);\n\x20\x20g.addEdge(0, 2);\n\x20\x20g.addEdge(1, 3);\n\x20\x20g.addEdge(2, 4);\n\x20\x20g.addEdge(3, 4);\n\x20\x20g.addEdge(4, 0);\n\n\x20\x20g.printGraph();\n\n\x20\x20return\x200;\n}\n