Skip to content

Commit 426f776

Browse files
committed
Add more wrappers for Graphs functions
1 parent 04a3442 commit 426f776

File tree

5 files changed

+497
-69
lines changed

5 files changed

+497
-69
lines changed

src/Graphs/abstractgraph.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ function subgraph(f::Function, graph::AbstractGraph)
7474
return induced_subgraph(graph, filter(f, vertices(graph)))[1]
7575
end
7676

77+
function degrees(graph::AbstractGraph, vertices=vertices(graph))
78+
return map(vertex -> degree(graph, vertex), vertices)
79+
end
80+
81+
function indegrees(graph::AbstractGraph, vertices=vertices(graph))
82+
return map(vertex -> indegree(graph, vertex), vertices)
83+
end
84+
85+
function outdegrees(graph::AbstractGraph, vertices=vertices(graph))
86+
return map(vertex -> outdegree(graph, vertex), vertices)
87+
end
88+
7789
# Used for tree iteration.
7890
# Assumes the graph is a [rooted directed tree](https://en.wikipedia.org/wiki/Tree_(graph_theory)#Rooted_tree).
7991
struct TreeGraph{G,V}

src/NamedGraphs.jl

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ import Graphs:
1919
bfs_parents,
2020
bfs_tree,
2121
blockdiag,
22+
common_neighbors,
23+
degree,
24+
degree_histogram,
2225
dst,
2326
dfs_parents,
2427
dfs_tree,
2528
edges,
2629
edgetype,
2730
has_edge,
31+
has_path,
2832
has_vertex,
33+
indegree,
2934
induced_subgraph,
3035
inneighbors,
3136
is_connected,
@@ -35,6 +40,21 @@ import Graphs:
3540
is_weakly_connected,
3641
ne,
3742
neighbors,
43+
neighborhood,
44+
neighborhood_dists,
45+
outdegree,
46+
a_star,
47+
bellman_ford_shortest_paths,
48+
enumerate_paths,
49+
desopo_pape_shortest_paths,
50+
dijkstra_shortest_paths,
51+
floyd_warshall_shortest_paths,
52+
johnson_shortest_paths,
53+
spfa_shortest_paths,
54+
yen_k_shortest_paths,
55+
boruvka_mst,
56+
kruskal_mst,
57+
prim_mst,
3858
nv,
3959
outneighbors,
4060
rem_vertex!,
@@ -43,11 +63,11 @@ import Graphs:
4363
tree,
4464
vertices
4565

46-
import Base: show, eltype, copy, getindex, convert, hcat, vcat, hvncat, union
66+
import Base: show, eltype, copy, getindex, convert, hcat, vcat, hvncat, union, zero
4767

4868
# abstractnamededge.jl
4969
import Base: Pair, Tuple, show, ==, hash, eltype, convert
50-
import Graphs: AbstractEdge, src, dst, reverse
70+
import Graphs: AbstractEdge, src, dst, reverse, reverse!
5171

5272
include(joinpath("Dictionaries", "dictionary.jl"))
5373
include(joinpath("Graphs", "abstractgraph.jl"))
@@ -75,6 +95,12 @@ export NamedGraph,
7595
post_order_dfs_vertices,
7696
post_order_dfs_edges,
7797
rename_vertices,
98+
degree,
99+
degrees,
100+
indegree,
101+
indegrees,
102+
outdegree,
103+
outdegrees,
78104
# Operations for tree-like graphs
79105
is_leaf,
80106
is_tree,

0 commit comments

Comments
 (0)