diff --git a/README.md b/README.md index e84ce11c..dc07a1ea 100755 --- a/README.md +++ b/README.md @@ -140,14 +140,23 @@ For self-compiled installations using CMake, execute the following from the comm ## How to use -To use the library **simply include the header file `CXXGraph.hpp`**, (make sure to add the [include folder](https://github.com/ZigRazor/CXXGraph/tree/master/include) to your compiler's inlcude path). +[//]: # (To use the library **simply include the header file `CXXGraph.hpp`**, (make sure to add the [include folder](https://github.com/ZigRazor/CXXGraph/tree/master/include) to your compiler's inlcude path).) +To use the library, simply include the `CXXGraph/CXXGraph.hpp` file at the top of your file. + +While compiling the file, include the two include paths mentioned in the `To compile and run the program` section in the command. CXXGraph revolves around the graph object which contains nodes and edges. This object can then be manipulated with a wide variety of algorithms. Please see the [examples section](#examples), [examples folder](https://github.com/ZigRazor/CXXGraph/tree/master/examples) and [website](https://zigrazor.github.io/CXXGraph/) for more information ## Examples -In this example, the shortest path between nodeA and nodeC is obtained using Dijkstra's algorithm. +In this example file `example.cpp`, the shortest path between nodeA and nodeC is obtained using Dijkstra's algorithm. +```bash +$ mkdir folder +$ cd folder +$ touch example.cpp +``` +Paste the below code into example.cpp ```cpp #include #include "CXXGraph/CXXGraph.hpp" @@ -162,9 +171,9 @@ int main(){ CXXGraph::UndirectedWeightedEdge edge3("3", nodeA, nodeC, 6); CXXGraph::T_EdgeSet edgeSet; - edgeSet.insert(make_shared>(edge1)); - edgeSet.insert(make_shared>(edge2)); - edgeSet.insert(make_shared>(edge3)); + edgeSet.insert(std::make_shared>(edge1)); + edgeSet.insert(std::make_shared>(edge2)); + edgeSet.insert(std::make_shared>(edge3)); CXXGraph::Graph graph(edgeSet); CXXGraph::DijkstraResult res = graph.dijkstra(nodeA, nodeC); @@ -175,6 +184,21 @@ int main(){ } ``` +### To compile and run the program + +Use the following command to compile the program: +``` bash +# while the path points to /folder/ + +$ g++ -I \ + -I -std=c++17 +``` +This will generate an executable binary `a.out`. +Use the following command to run the compiled binary: +``` +./a.out +``` + See more examples in the [examples folder](https://github.com/ZigRazor/CXXGraph/tree/master/examples). ## Unit-Test Execution