Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/layout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ julia> g = simple_house_graph()
julia> locs_x, locs_y = circular_layout(g)
```
"""
function circular_layout(g)
function circular_layout(g::AbstractGraph{T}) where {T<:Integer}
if nv(g) == 1
return [0.0], [0.0]
else
# Discard the extra angle since it matches 0 radians.
θ = range(0, stop=2pi, length=_nv(G)+1)[1:end-1]
θ = range(0, stop=2pi, length=nv(g)+1)[1:end-1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, we really need more tests, so errors like this one do not get unnoticed.

return cos.(θ), sin.(θ)
end
end
Expand Down
13 changes: 12 additions & 1 deletion src/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ function gplot(g::AbstractGraph{T},
nodefillc = colorant"turquoise",
nodestrokec = nothing,
nodestrokelw = 0.0,
node_bitmap = [],
arrowlengthfrac = is_directed(g) ? 0.1 : 0.0,
arrowangleoffset = π / 9.0,
linetype = "straight",
Expand Down Expand Up @@ -163,7 +164,15 @@ function gplot(g::AbstractGraph{T},
nodecircle[i] *= nodesize[i]
end
end
nodes = circle(locs_x, locs_y, nodecircle)

if isempty(node_bitmap)
nodes = circle(locs_x, locs_y, nodecircle)
else
bsize = 3*nodesize
xc = locs_x .- bsize/2
yc = locs_y .- bsize/2
nodes = bitmap(["image/png"], node_bitmap, xc, yc, [bsize], [bsize])
end

# Create node labels if provided
texts = nothing
Expand Down Expand Up @@ -216,9 +225,11 @@ function gplot(g::AbstractGraph{T},
compose(context(units=UnitBox(-1.2, -1.2, +2.4, +2.4)),
compose(context(), texts, fill(nodelabelc), stroke(nothing), fontsize(nodelabelsize)),
compose(context(), nodes, fill(nodefillc), stroke(nodestrokec), linewidth(nodestrokelw)),
#compose(context(), nodes),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why that?

compose(context(), edgetexts, fill(edgelabelc), stroke(nothing), fontsize(edgelabelsize)),
compose(context(), arrows, stroke(edgestrokec), linewidth(edgelinewidth)),
compose(context(), lines, stroke(edgestrokec), fill(nothing), linewidth(edgelinewidth)))

end

function gplot(g; layout::Function=spring_layout, keyargs...)
Expand Down