Skip to content

Commit c02bfcb

Browse files
committed
fixes
1 parent 44c278e commit c02bfcb

File tree

7 files changed

+91
-13
lines changed

7 files changed

+91
-13
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ version = "0.1.0"
77
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
88
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
99
MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5"
10+
Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
1011

1112
[compat]
1213
julia = "1"

src/CitationNetworks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ include("mainpath_gbfp.jl")
1818
include("genetic_knowper.jl")
1919
include("convenience.jl")
2020

21-
export compute_weights_spc, add_weights
21+
export weights_spc, add_weights
2222
export mainpath, ForwardLocal, BackwardLocal, StandardGlobal, GBFP
2323
export genetic_knowper
2424
export set_mp_prop!

src/convenience.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ function set_mp_prop!(g::MetaDiGraph{T, U}, mp::MainPathResult, sym::Symbol) whe
77
[set_prop!(g, v, sym, true) for v in vmp]
88
end
99

10-
function add_weights(g::SimpleDiGraph{T}, weights::Vector{U}) where T <: Integer where U <: Real
11-
from = [src(e) for e in edges(g)]
12-
to = [dst(e) for e in edges(g)]
13-
SimpleWeightedDiGraph(from, to, weights)
14-
end
10+
# function add_weights(g::SimpleDiGraph{T}, weights::Vector{U}) where T <: Integer where U <: Real
11+
# from = [src(e) for e in edges(g)]
12+
# to = [dst(e) for e in edges(g)]
13+
# SimpleWeightedDiGraph(from, to, weights)
14+
# end

src/mainpath_gbfp.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ function mainpath(
2828
gkp = genetic_knowper(g, normalize=normalize)
2929
start = findall(gkp .>= cutoff)
3030

31-
edges = Vector{SimpleEdge{T}}()
32-
state = MainPathState(edges)
33-
traverse_graph!(g, start, BreadthFirst(neighborfn = (g, v) -> vmax_outneighbors(g, v, gkp)), state)
34-
traverse_graph!(g, start, BreadthFirst(neighborfn = (g, v) -> vmax_outneighbors(g, v, gkp)), state)
31+
forwardstate = MainPathState(Vector{SimpleEdge{T}}())
32+
backwardstate = MainPathState(Vector{SimpleEdge{T}}())
33+
traverse_graph!(g, start, BreadthFirst(neighborfn = (g, v) -> vmax_outneighbors(g, v, gkp)), forwardstate)
34+
traverse_graph!(g, start, BreadthFirst(neighborfn = (g, v) -> vmax_inneighbors(g, v, gkp)), backwardstate)
3535

36-
return GBFPResult(state.edges)
36+
combined = vcat(forwardstate.edges, reverse.(backwardstate.edges)) |> unique
37+
return GBFPResult(combined)
3738
end

src/weights_spc.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ add_source_target! = function(g::AbstractGraph{T}) where T <: Integer
1818
end
1919

2020

21-
compute_weights_spc = function(g::AbstractGraph{T}; normalize = false) where T <: Integer
21+
weights_spc = function(g::AbstractGraph{T}; normalize = false) where T <: Integer
2222

2323
N⁻ = function(g::SimpleDiGraph{T}, vseqt::Vector{T}) where T <: Integer
2424
nV = length(vseqt)

test/demo.jl

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
### A Pluto.jl notebook ###
2+
# v0.11.14
3+
4+
using Markdown
5+
using InteractiveUtils
6+
7+
# ╔═╡ 0120e370-f8f5-11ea-1b65-9d29b0b5b647
8+
begin
9+
using LightGraphs
10+
using LightGraphs.SimpleGraphs
11+
using MetaGraphs
12+
using CitationNetworks
13+
using GraphPlot
14+
end
15+
16+
# ╔═╡ 0ba77020-f8f5-11ea-025d-61768c938c5c
17+
A = [
18+
0 0 1 0 0 0 0 0 0 0 0
19+
0 0 1 1 0 0 0 0 0 0 0
20+
0 0 0 0 1 0 1 0 0 0 0
21+
0 0 0 0 0 1 0 0 0 1 1
22+
0 0 0 0 0 0 0 1 1 0 0
23+
0 0 0 0 0 0 0 0 1 1 0
24+
0 0 0 0 0 0 0 0 0 0 0
25+
0 0 0 0 0 0 0 0 0 0 0
26+
0 0 0 0 0 0 0 0 0 0 0
27+
0 0 0 0 0 0 0 0 0 0 0
28+
0 0 0 0 0 0 0 0 0 0 0
29+
];
30+
31+
# ╔═╡ 2680e980-f8f5-11ea-10c2-fbf1d8358506
32+
g = SimpleDiGraph(A)
33+
34+
# ╔═╡ 53e56540-f8f5-11ea-1189-99d9421b9146
35+
gplot(g, nodelabel=1:nv(g))
36+
37+
# ╔═╡ 7563a7d0-f8f6-11ea-00ae-bbee824a385c
38+
genetic_knowper(g, normalize=:none)
39+
40+
# ╔═╡ 6b60e68e-f8f5-11ea-25f9-f3075e37b317
41+
mpres = mainpath(g, 3, GBFP(), normalize=:none)
42+
43+
# ╔═╡ 3404b0a0-f8f5-11ea-1cb0-4f35dff35a1f
44+
mpnet, vlabels = induced_subgraph(g, mpres.edges)
45+
46+
# ╔═╡ bd8334f0-f8f5-11ea-0def-dda12adf86e7
47+
gplot(mpnet, nodelabel=vlabels)
48+
49+
# ╔═╡ 5bb78380-f8f9-11ea-2b66-1529d729d0d9
50+
function add_weights(g, w)
51+
mg = MetaDiGraph(g)
52+
for (i,e) in enumerate(edges(g))
53+
set_prop!(mg, e, :weight, w[i])
54+
end
55+
return mg
56+
end
57+
58+
# ╔═╡ c9fba690-f8f5-11ea-068f-7393d3245730
59+
begin
60+
spc = weights_spc(g).edgeweights
61+
mg = add_weights(g, spc)
62+
mpfl = mainpath(mg, ForwardLocal())
63+
mpbl = mainpath(mg, BackwardLocal())
64+
end
65+
66+
# ╔═╡ Cell order:
67+
# ╠═0120e370-f8f5-11ea-1b65-9d29b0b5b647
68+
# ╠═0ba77020-f8f5-11ea-025d-61768c938c5c
69+
# ╠═2680e980-f8f5-11ea-10c2-fbf1d8358506
70+
# ╠═53e56540-f8f5-11ea-1189-99d9421b9146
71+
# ╠═7563a7d0-f8f6-11ea-00ae-bbee824a385c
72+
# ╠═6b60e68e-f8f5-11ea-25f9-f3075e37b317
73+
# ╠═3404b0a0-f8f5-11ea-1cb0-4f35dff35a1f
74+
# ╠═bd8334f0-f8f5-11ea-0def-dda12adf86e7
75+
# ╠═5bb78380-f8f9-11ea-2b66-1529d729d0d9
76+
# ╠═c9fba690-f8f5-11ea-068f-7393d3245730

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ A = [
2222

2323
g = SimpleDiGraph(A)
2424

25-
ew_spc, vw_spc, tf_spc = compute_weights_spc(g, normalize = false)
25+
ew_spc, vw_spc, tf_spc = weights_spc(g, normalize = false)
2626

2727
# MetaDiGraph
2828

0 commit comments

Comments
 (0)