Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ using GraphPlot
# Usage
## karate network
```julia
g = graphfamous("karate")
using LightGraphs: smallgraph
g = smallgraph(:karate)
gplot(g)

```

## Add node label
```julia
using Graphs
nodelabel = [1:num_vertices(g)]
using LightGraphs
nodelabel = [1:nv(g)]
gplot(g, nodelabel=nodelabel)

```
Expand All @@ -46,7 +47,7 @@ gplot(g, nodelabel=nodelabel, nodelabeldist=1.5, nodelabelangleoffset=π/4)
## Control the node size
```julia
# nodes size proportional to their degree
nodesize = [Graphs.out_degree(v, g) for v in Graphs.vertices(g)]
nodesize = [LightGraphs.out_degree(g, v) for v in LightGraphs.vertices(g)]
gplot(g, nodesize=nodesize)
```

Expand All @@ -56,7 +57,7 @@ Feed the keyword argument `nodefillc` a color array, ensure each node has a colo
using Colors

# Generate n maximally distinguishable colors in LCHab space.
nodefillc = distinguishable_colors(num_vertices(g), colorant"blue")
nodefillc = distinguishable_colors(nv(g), colorant"blue")
gplot(g, nodefillc=nodefillc, nodelabel=nodelabel, nodelabeldist=1.8, nodelabelangleoffset=π/4)
```

Expand All @@ -75,13 +76,13 @@ gplot(g, nodelabelsize=nodelabelsize, nodesize=nodesize, nodelabel=nodelabel)

## Draw edge labels
```julia
edgelabel = [1:Graphs.num_edges(g)]
edgelabel = [1:LightGraphs.ne(g)]
gplot(g, edgelabel=edgelabel, nodelabel=nodelabel)
```

## Adjust edge labels
```julia
edgelabel = [1:Graphs.num_edges(g)]
edgelabel = [1:LightGraphs.ne(g)]
gplot(g, edgelabel=edgelabel, nodelabel=nodelabel, edgelabeldistx=0.5, edgelabeldisty=0.5)
```

Expand Down Expand Up @@ -119,9 +120,9 @@ gplot(g, layout=spectral_layout)
```
### shell layout
```julia
nlist = Array(Vector{Int}, 2) # two shells
nlist = Vector{Vector{Int}}(undef, 2) # two shells
nlist[1] = [1:5] # first shell
nlist[2] = [6:num_vertices(g)] # second shell
nlist[2] = [6:nv(g)] # second shell
locs_x, locs_y = shell_layout(g, nlist)
gplot(g, locs_x, locs_y, nodelabel=nodelabel)
```
Expand All @@ -133,7 +134,7 @@ gplot(g, linetype="curve")

## Save to figure
```{execute="false"}
using Compose
using Cairo, Compose
# save to pdf
draw(PDF("karate.pdf", 16cm, 16cm), gplot(g))
# save to png
Expand Down