Skip to content

Commit

Permalink
again
Browse files Browse the repository at this point in the history
  • Loading branch information
BeastyBlacksmith committed Nov 8, 2021
1 parent 66cda88 commit 615b7f4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 25 deletions.
3 changes: 1 addition & 2 deletions src/GraphRecipes.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Graphs
module GraphRecipes

using LightGraphs
using Graphs
import NetworkLayout
using PlotUtils # ColorGradient
using RecipesBase
Expand Down
34 changes: 17 additions & 17 deletions src/graphs.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Graphsconst _graph_funcs = Dict{Symbol,Any}(
const _graph_funcs = Dict{Symbol,Any}(
:spectral => spectral_graph,
:sfdp => sfdp_graph,
:circular => circular_graph,
Expand Down Expand Up @@ -162,14 +162,14 @@ function compute_laplacian(adjmat::AbstractMatrix, node_weights::AbstractVector)
L, D
end

import LightGraphs
import Graphs

# TODO: so much wasteful conversion... do better
function estimate_distance(adjmat::AbstractMatrix)
source, destiny, weights = get_source_destiny_weight(sparse(adjmat))

g = LightGraphs.Graph(adjmat)
dists = convert(Matrix{Float64}, hcat(map(i->LightGraphs.dijkstra_shortest_paths(g, i).dists, LightGraphs.vertices(g))...))
g = Graphs.Graph(adjmat)
dists = convert(Matrix{Float64}, hcat(map(i->Graphs.dijkstra_shortest_paths(g, i).dists, Graphs.vertices(g))...))
tot = 0.0; cnt = 0
for (i,d) in enumerate(dists)
if d < 1e10
Expand All @@ -186,27 +186,27 @@ function estimate_distance(adjmat::AbstractMatrix)
dists
end

function get_source_destiny_weight(g::LightGraphs.AbstractGraph)
function get_source_destiny_weight(g::Graphs.AbstractGraph)
source = Vector{Int}()
destiny = Vector{Int}()
sizehint!(source, LightGraphs.nv(g))
sizehint!(destiny, LightGraphs.nv(g))
for e in LightGraphs.edges(g)
push!(source, LightGraphs.src(e))
push!(destiny, LightGraphs.dst(e))
sizehint!(source, Graphs.nv(g))
sizehint!(destiny, Graphs.nv(g))
for e in Graphs.edges(g)
push!(source, Graphs.src(e))
push!(destiny, Graphs.dst(e))
end
get_source_destiny_weight(source, destiny)
end

function get_adjacency_matrix(g::LightGraphs.AbstractGraph)
function get_adjacency_matrix(g::Graphs.AbstractGraph)
adjacency_matrix(g)
end

function get_adjacency_matrix(source::AbstractVector{Int}, destiny::AbstractVector{Int})
get_adjacency_matrix(source, destiny, ones(length(source)))
end

function get_adjacency_list(g::LightGraphs.AbstractGraph)
function get_adjacency_list(g::Graphs.AbstractGraph)
g.fadjlist
end

Expand Down Expand Up @@ -243,7 +243,7 @@ const graph_aliases = Dict(:curvature_scalar => [:curvaturescalar,:curvature],
graphplot(g; kwargs...)
Visualize the graph `g`, where `g` represents a graph via a matrix or a
`LightGraphs.graph`.
`Graphs.graph`.
## Keyword arguments
```
dim = 2
Expand Down Expand Up @@ -325,12 +325,12 @@ more details.
edgecolor = :black,
edgestyle = :solid,
)
# Process the args so that they are a LightGraphs.Graph.
if length(g.args) <= 1 && !(eltype(g.args[1]) <: AbstractArray) && !(g.args[1] isa LightGraphs.AbstractGraph) && method != :chorddiagram && method != :arcdiagram
# Process the args so that they are a Graphs.Graph.
if length(g.args) <= 1 && !(eltype(g.args[1]) <: AbstractArray) && !(g.args[1] isa Graphs.AbstractGraph) && method != :chorddiagram && method != :arcdiagram
if !LinearAlgebra.issymmetric(g.args[1]) || any(diag(g.args[1]) .!= zeros(length(diag(g.args[1]))))
g.args = (LightGraphs.DiGraph(g.args[1]),)
g.args = (Graphs.DiGraph(g.args[1]),)
elseif LinearAlgebra.issymmetric(g.args[1])
g.args = (LightGraphs.Graph(g.args[1]),)
g.args = (Graphs.Graph(g.args[1]),)
end
end

Expand Down
3 changes: 1 addition & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Graphs
"""
This function builds a BezierCurve which leaves point p vertically upwards and
arrives point q vertically upwards. It may create a loop if necessary.
Expand Down Expand Up @@ -231,7 +230,7 @@ end
function process_edge_attribute(attr, source, destiny, weights)
if isnothing(attr) || (attr isa Symbol)
return attr
elseif attr isa LightGraphs.AbstractGraph
elseif attr isa Graphs.AbstractGraph
mat = incidence_matrix(attr)
attr = [mat[si, di] for (si, di) in zip(source, destiny)][:] |> permutedims
elseif attr isa Function
Expand Down
4 changes: 2 additions & 2 deletions test/figures.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Graphsusing StableRNGs
using StableRNGs
using VisualRegressionTests
using LinearAlgebra
using SparseArrays
using ImageMagick
using LightGraphs
using Graphs
using AbstractTrees

cd(@__DIR__)
Expand Down
4 changes: 2 additions & 2 deletions test/generate_figures.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Graphsusing StableRNGs
GraphsGraphsusing StableRNGs
using LinearAlgebra
using SparseArrays
using GraphRecipes
using Plots
using LightGraphs
using Graphs
using AbstractTrees

cd(@__DIR__)
Expand Down

2 comments on commit 615b7f4

@BeastyBlacksmith
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/48429

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.8 -m "<description of version>" 615b7f46579d9607ad5eef945dc65154fa93c768
git push origin v0.5.8

Please sign in to comment.