## EmbeddedGraphs.jl

Embedded Graphs for Julia
Author FHell
Popularity
3 Stars
Updated Last
1 Year Ago
Started In
March 2019

# EmbeddedGraphs.jl # Example usage

The example requires

```using EmbeddedGraphs
using Distances
using LightGraphs```

Set the position of the vertices that need to be placed on the graph

`positions = map(i->[rand(),rand()], 1:10)`

Create the graph with a given SimpleGraph structure and positions

`eg = EmbeddedGraph(SimpleGraph(10), positions)`

In case you want to have a different metric this is possible with a third argument, where the points `P` and `Q` should be the positions of the vertices.

`eg_minkowski = EmbeddedGraph(SimpleGraph(10), positions, (P, Q) -> minkowski(P, Q, 2.))`

Calculate the distance between two vertices ...

`eg[1,9]`

... or likewise

`euclidean(eg.vertexpos, eg.vertexpos)`

Get the x value of all the vertices ...

`vertices_loc(eg, 1)`

... or y location

`vertices_loc(eg, 2)`

Get the Weightsmatrix with distances between every vertex ...

`weights(eg, dense=true)`

... or only a sparse matrix with only connected vertices

`weights(eg, dense=false)`

```add_edge!(eg, 1, 9)

Remove an edge

`rem_edge!(eg, 1, 9)`

Add a vertex at position `(0.1, 0.7)`

`add_vertex!(eg, [0.1, 0.7])`

Remove a vertex

```rem_vertex!(eg, 5)
rem_vertices!(eg, [1, 2, 3])```

Plot the graph embedded in 2D

`gplot(eg)`