Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to 20211026 #3

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
20343ab
Fix for corner case where spread is zero
nmoran May 25, 2020
2ed414a
Fix readme minor example errors.
jzazo Jul 3, 2020
e339d2f
Update README.md
mthelm85 Jul 15, 2020
d734b6a
Merge pull request #118 from mthelm85/patch-1
simonschoelly Sep 10, 2020
692e6e1
Merge pull request #117 from jzazo/update_readme
simonschoelly Sep 10, 2020
7e5ce6c
Add Julia 1.5 to .travis
simonschoelly Sep 10, 2020
8c00460
Bump version to v0.4.3
simonschoelly Sep 10, 2020
6e1820a
Remove obsolete REQUIRE file
simonschoelly Sep 10, 2020
36a466b
Make min Julia version 1.3
simonschoelly Sep 10, 2020
2f075b1
Merge pull request #122 from simonschoelly/create-version-0.4.3
simonschoelly Sep 11, 2020
88388f8
typo in shell_layout example
jarlebring Sep 17, 2020
3c8032e
Setup CompatHelper
simonschoelly Sep 21, 2020
d1c37b0
Merge pull request #124 from simonschoelly/add-CompatHelper
simonschoelly Sep 21, 2020
c8647e8
Update compose version
simonschoelly Sep 22, 2020
ce94183
Merge pull request #123 from jarlebring/master
simonschoelly Sep 22, 2020
f6dcbf5
Merge pull request #112 from nmoran/layout-extrema-corner-case
simonschoelly Sep 22, 2020
2ce59f9
Merge pull request #126 from simonschoelly/update-compose-version
simonschoelly Sep 22, 2020
b81a0ad
CompatHelper: bump compat for "ArnoldiMethod" to "0.1"
github-actions[bot] Dec 18, 2020
cf9760e
Merge pull request #136 from JuliaGraphs/compathelper/new_version/202…
simonschoelly Dec 19, 2020
b8b349a
Switch from travis to github ci (#137)
simonschoelly Dec 19, 2020
2ca9bbe
Replace travis badge with github ci badge
simonschoelly Dec 19, 2020
65e546d
Replace pkg.julialang badge with juliahub badge
simonschoelly Dec 19, 2020
e970637
Merge pull request #138 from simonschoelly/update-readme-badges
simonschoelly Dec 19, 2020
474209c
Add version 1 for VisualRegressionTest dependency
simonschoelly Dec 19, 2020
6415b7f
Merge pull request #139 from simonschoelly/bump-isualRegressionTests-…
simonschoelly Dec 19, 2020
1f2a7c5
Bump version to v0.4.4
simonschoelly Dec 19, 2020
b2a5b0b
Merge pull request #140 from simonschoelly/create-version-0.4.4
simonschoelly Dec 19, 2020
9e734d5
Migrate from LightGraphs to Graphs.jl
simonschoelly Oct 17, 2021
139d4e9
Restrict VisualRegressionTests version
simonschoelly Oct 20, 2021
a04b5cf
Migrate from LightGraphs to Graphs.jl
simonschoelly Oct 21, 2021
0444e49
Bump ColorTypes to "0.9, 0.10, 0.11"
ven-k Mar 10, 2022
100611e
Merge pull request #163 from ven-k/patch-1
simonschoelly May 11, 2022
0d1bf36
Create test/Project.toml
fonsp May 11, 2022
1d090ad
Merge pull request #164 from fonsp/fix-1.3-tests
simonschoelly May 11, 2022
4484ca3
remove mention of num_vertices and num_edges in the documentation
etiennedeg May 23, 2022
5d2ec58
Merge pull request #169 from etiennedeg/doc_num_vertices
etiennedeg May 23, 2022
e858981
CompatHelper: bump compat for ArnoldiMethod to 0.2, (keep existing co…
github-actions[bot] May 23, 2022
a509148
bump version to v0.5.2 (#170)
etiennedeg May 24, 2022
9e0d037
remove deprecation message when testing (#171)
etiennedeg Jun 1, 2022
52f4aae
Improve documentation; fix `gplothtml`; add TagBot (#174)
hdavid16 Jul 26, 2022
8ebe46b
Add requested features (#186)
hdavid16 May 12, 2024
3a7daa0
minor release (#200)
etiennedeg May 15, 2024
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
16 changes: 16 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CompatHelper
on:
schedule:
- cron: '00 00 * * *'
workflow_dispatch:
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.COMPATHELPER_PRIV }} # optional
run: julia -e 'using CompatHelper; CompatHelper.main()'
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI
on:
pull_request:
branches:
- master
push:
branches:
- master
tags: '*'
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.6' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
- '1' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
- 'nightly'
os:
- ubuntu-latest
- macos-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
20 changes: 20 additions & 0 deletions .github/workflows/tagbot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: 3
permissions:
contents: write
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

26 changes: 7 additions & 19 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
name = "GraphPlot"
uuid = "a2cc645c-3eea-5389-862e-a155d0052231"
authors = ["JuliaGraphs"]
version = "0.4.2"
version = "0.6.0"

[deps]
ArnoldiMethod = "ec485272-7323-5ecc-a04f-4719b315124d"
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
ArnoldiMethod = "0.0.4"
ColorTypes = "0.9, 0.10"
Colors = "0.11, 0.12"
Compose = "0.7, 0.8"
LightGraphs = "1.1"
VisualRegressionTests = "0.2, 0.3"
julia = "1"

[extras]
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92"

[targets]
test = ["Test", "Cairo", "ImageMagick", "VisualRegressionTests"]
ArnoldiMethod = "0.2"
Colors = "0.12"
Compose = "0.9"
Graphs = "1.4"
julia = "1.6"
89 changes: 59 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GraphPlot

[![Build Status](https://travis-ci.org/JuliaGraphs/GraphPlot.jl.svg?branch=master)](https://travis-ci.org/JuliaGraphs/GraphPlot.jl)
[![Julia Build](http://pkg.julialang.org/badges/GraphPlot_0.6.svg)](http://pkg.julialang.org/?pkg=GraphPlot)
![CI](https://github.com/JuliaGraphs/GraphPlot.jl/workflows/CI/badge.svg?branch=master)
[![version](https://juliahub.com/docs/GraphPlot/version.svg)](https://juliahub.com/ui/Packages/GraphPlot/bUwXr)

Graph layout and visualization algorithms based on [Compose.jl](https://github.com/dcjones/Compose.jl) and inspired by [GraphLayout.jl](https://github.com/IainNZ/GraphLayout.jl).

Expand All @@ -14,7 +14,7 @@ Other layout algorithms are wrapped from [NetworkX](https://github.com/networkx/
# Getting Started

From the Julia REPL the latest version can be installed with
```{execute="false"}
```julia
Pkg.add("GraphPlot")
```
GraphPlot is then loaded with
Expand All @@ -25,16 +25,16 @@ using GraphPlot
# Usage
## karate network
```julia
using LightGraphs: smallgraph
using Graphs: smallgraph
g = smallgraph(:karate)
gplot(g)

```

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

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

Expand Down Expand Up @@ -76,13 +76,13 @@ gplot(g, nodelabelsize=nodelabelsize, nodesize=nodesize, nodelabel=nodelabel)

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

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

Expand All @@ -99,7 +99,7 @@ gplot(g, nodefillc=nodefillc)
## Different layout

### spring layout (default)
This is the defaut layout and will be chosen if no layout is specified. The [default parameters to the spring layout algorithm](https://github.com/JuliaGraphs/GraphPlot.jl/blob/master/src/layout.jl#L78) can be changed by supplying an anonymous function, e.g., if nodes appear clustered too tightly together, try
This is the defaut layout and will be chosen if no layout is specified. The [default parameters to the spring layout algorithm](https://github.com/JuliaGraphs/GraphPlot.jl/blob/master/src/layout.jl#L78) can be changed by supplying an anonymous function, e.g., if nodes appear clustered too tightly together, try
```julia
layout=(args...)->spring_layout(args...; C=20)
gplot(g, layout=layout, nodelabel=nodelabel)
Expand All @@ -121,8 +121,8 @@ gplot(g, layout=spectral_layout)
### shell layout
```julia
nlist = Vector{Vector{Int}}(undef, 2) # two shells
nlist[1] = [1:5] # first shell
nlist[2] = [6:nv(g)] # second shell
nlist[1] = 1:5 # first 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 @@ -132,38 +132,67 @@ gplot(g, locs_x, locs_y, nodelabel=nodelabel)
gplot(g, linetype="curve")
```

## Show plot

When using an IDE such as VSCode, `Cairo.jl` is required to visualize the plot inside the IDE.
When using the REPL, `gplothtml` will allow displaying the plot on a browser.

## Save to figure
```{execute="false"}
using Cairo, Compose
```julia
using Compose
# save to pdf
draw(PDF("karate.pdf", 16cm, 16cm), gplot(g))
# save to png
draw(PNG("karate.png", 16cm, 16cm), gplot(g))
# save to svg
draw(SVG("karate.svg", 16cm, 16cm), gplot(g))
# alternate way of saving to svg without loading Compose
saveplot(gplot(g, plot_size = (16cm, 16cm)), "karate.svg")
```
# LightGraphs integration
# Graphs.jl integration
```julia
using LightGraphs
using Graphs
h = watts_strogatz(50, 6, 0.3)
gplot(h)
```

# Arguments
+ `G` graph to plot
+ `layout` Optional. layout algorithm. Currently can choose from
[random_layout, circular_layout, spring_layout, stressmajorize_layout,
shell_layout, spectral_layout].
Default: `spring_layout`
+ `nodelabel` Optional. Labels for the vertices. Default: `nothing`
+ `nodefillc` Optional. Color to fill the nodes with.
Default: `colorant"turquoise"`
+ `nodestrokec` Color for the node stroke.
Default: `nothing`
+ `arrowlengthfrac` Fraction of line length to use for arrows.
Set to 0 for no arrows. Default: 0 for undirected graph and 0.1 for directed graph
+ `arrowangleoffset` angular width in radians for the arrows. Default: `π/9` (20 degrees)

+ `G` Graph to draw
+ `locs_x, locs_y` Locations of the nodes (will be normalized and centered). If not specified, will be obtained from `layout` kwarg.

# Keyword Arguments
+ `layout` Layout algorithm: `random_layout`, `circular_layout`, `spring_layout`, `shell_layout`, `stressmajorize_layout`, `spectral_layout`. Default: `spring_layout`
+ `title` Plot title. Default: `""`
+ `title_color` Plot title color. Default: `colorant"black"`
+ `title_size` Plot title size. Default: `4.0`
+ `font_family` Font family for all text. Default: `"Helvetica"`
+ `NODESIZE` Max size for the nodes. Default: `3.0/sqrt(N)`
+ `nodesize` Relative size for the nodes, can be a Vector. Default: `1.0`
+ `nodelabel` Labels for the vertices, a Vector or nothing. Default: `nothing`
+ `nodelabelc` Color for the node labels, can be a Vector. Default: `colorant"black"`
+ `nodelabeldist` Distances for the node labels from center of nodes. Default: `0.0`
+ `nodelabelangleoffset` Angle offset for the node labels. Default: `π/4.0`
+ `NODELABELSIZE` Largest fontsize for the vertice labels. Default: `4.0`
+ `nodelabelsize` Relative fontsize for the vertice labels, can be a Vector. Default: `1.0`
+ `nodefillc` Color to fill the nodes with, can be a Vector. Default: `colorant"turquoise"`
+ `nodestrokec` Color for the nodes stroke, can be a Vector. Default: `nothing`
+ `nodestrokelw` Line width for the nodes stroke, can be a Vector. Default: `0.0`
+ `edgelabel` Labels for the edges, a Vector or nothing. Default: `[]`
+ `edgelabelc` Color for the edge labels, can be a Vector. Default: `colorant"black"`
+ `edgelabeldistx, edgelabeldisty` Distance for the edge label from center of edge. Default: `0.0`
+ `EDGELABELSIZE` Largest fontsize for the edge labels. Default: `4.0`
+ `edgelabelsize` Relative fontsize for the edge labels, can be a Vector. Default: `1.0`
+ `EDGELINEWIDTH` Max line width for the edges. Default: `0.25/sqrt(N)`
+ `edgelinewidth` Relative line width for the edges, can be a Vector. Default: `1.0`
+ `edgestrokec` Color for the edge strokes, can be a Vector. Default: `colorant"lightgray"`
+ `arrowlengthfrac` Fraction of line length to use for arrows. Equal to 0 for undirected graphs. Default: `0.1` for the directed graphs
+ `arrowangleoffset` Angular width in radians for the arrows. Default: `π/9 (20 degrees)`
+ `linetype` Type of line used for edges ("straight", "curve"). Default: "straight"
+ `outangle` Angular width in radians for the edges (only used if `linetype = "curve`). Default: `π/5 (36 degrees)`
+ `background_color` Color for the plot background. Default: `nothing`
+ `plot_size` Tuple of measures for width x height of plot area. Default: `(10cm, 10cm)`
+ `leftpad, rightpad, toppad, bottompad` Padding for the plot margins. Default: `0mm`
+ `pad` Padding for plot margins (overrides individual padding if given). Default: `nothing`
# Reporting Bugs

Filing an issue to report a bug, counterintuitive behavior, or even to request a feature is extremely valuable in helping me prioritize what to work on, so don't hestitate.
6 changes: 0 additions & 6 deletions REQUIRE

This file was deleted.

4 changes: 2 additions & 2 deletions examples/graphplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"outputs": [],
"source": [
"# load needed package firstly\n",
"using LightGraphs\n",
"using Graphs\n",
"using GraphPlot"
]
},
Expand Down Expand Up @@ -12127,7 +12127,7 @@
}
},
"source": [
"# Native LightGraphs integration"
"# Native Graphs.jl integration"
]
},
{
Expand Down
6 changes: 4 additions & 2 deletions src/GraphPlot.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module GraphPlot

using Compose # for plotting features
using LightGraphs
using Graphs

const gadflyjs = joinpath(dirname(Base.source_path()), "gadfly.js")

Expand All @@ -15,7 +15,9 @@ export
spring_layout,
spectral_layout,
shell_layout,
stressmajorize_layout
stressmajorize_layout,
saveplot,
mm, cm, inch

include("deprecations.jl")

Expand Down
6 changes: 3 additions & 3 deletions src/collapse_plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ function community_layout(g::AbstractGraph, membership::Vector{Int})
end

function collapse_layout(g::AbstractGraph, membership::Vector{Int})
lightg = LightGraphs.SimpleGraph(nv(g))
sg = Graphs.SimpleGraph(nv(g))
for e in edges(g)
u = src(e)
v = dst(e)
LightGraphs.add_edge!(lightg, u, v)
Graphs.add_edge!(sg, u, v)
end
N = length(membership)
lx = zeros(N)
Expand All @@ -84,7 +84,7 @@ function collapse_layout(g::AbstractGraph, membership::Vector{Int})
h, w = collapse_graph(g, membership)
clx, cly = spring_layout(h)
for (lbl, nodes) in comms
subg = lightg[nodes]
subg = sg[nodes]
sublx, subly = spring_layout(subg)
θ = range(0, stop=2pi, length=(length(nodes) + 1))[1:end-1]
for (idx, node) in enumerate(nodes)
Expand Down
Loading