Skip to content

Commit

Permalink
docs: improve quickstart guide (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdhvg authored Oct 12, 2023
1 parent a00b392 commit 70e8c25
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 16 deletions.
4 changes: 3 additions & 1 deletion docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.docusaurus/
build/
node_modules/
node_modules/

yarn-error.log
53 changes: 52 additions & 1 deletion docs/docs/quickstart/basics/creating-your-first-graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,55 @@
sidebar_position: 2
---

# Creating Your First Graph
# Creating Your First Graph

1. In your `main.cpp` import Graaf:

```c++
#include <graaflib/graph.h>
```

2. Define a directed graph `g`

```c++
graaf::directed_graph<const char, int> g;
```

3. Add vertices to the graph:

```c++
const auto a = g.add_vertex('a');
const auto b = g.add_vertex('b');
const auto c = g.add_vertex('c');
```

4. Connect the vertices with edges:

```c++
g.add_edge(a, b, 1);
g.add_edge(a, c, 1);
```

5. Putting it all together:

```c++
#include <graaflib/graph.h>

int main()
{
graaf::directed_graph<const char, int> g;

const auto a = g.add_vertex('a');
const auto b = g.add_vertex('b');
const auto c = g.add_vertex('c');

g.add_edge(a, b, 1);
g.add_edge(a, c, 1);

return 0;
}
```

### Congratulations! You just created the following graph 🎉

![Directed graph example](../../../static/img/quickstart/Graph.png)
14 changes: 13 additions & 1 deletion docs/docs/quickstart/installation/alternative-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@
sidebar_position: 2
---

# Alternative Installation Methods
# Alternative Installation Methods

## As a submodule

Graaf can also be installed as a submodule in your project

1. Go to your project directory `cd projectdir`
1. Add Graaf as submodule `git submodule add https://github.com/bobluppes/graaf.git`
1. Then add Graaf as include directory with CMake:

```CMake
include_directories("graaf/include")
```
28 changes: 15 additions & 13 deletions docs/docs/quickstart/installation/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,25 @@ sidebar_position: 1
Installing Graaf on your project is easy! Simply copy the `graaflib` directory to your project and add it to your
include path.

1. Copy `graaflip` to your project.
1. Copy `graaflib` to your project.
2. Before compiling, add the directory to your include path.
```bash
# For C compiler
export C_INCLUDE_PATH="/full/path/to/include/graaflib/:$C_INCLUDE_PATH"
# For Cpp compiler
export CPLUS_INCLUDE_PATH="/full/path/to/include/graaflib/:$CPLUS_INCLUDE_PATH"
```

```bash
# For C compiler
export C_INCLUDE_PATH="/full/path/to/include/:$C_INCLUDE_PATH"
# For Cpp compiler
export CPLUS_INCLUDE_PATH="/full/path/to/include/:$CPLUS_INCLUDE_PATH"
```

Or in CMake:
```CMake
include_directories("graaf/src/graaflib")
```

```CMake
include_directories("graaf/include")
```

3. Include the graaf header in your sources.
```c++
#include <graaflib/directed_graph.h>
```
```c++
#include <graaflib/graph.h>

## CMake FetchContent

Expand Down
Binary file added docs/static/img/quickstart/Graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 70e8c25

Please sign in to comment.