Skip to content

Commit 80ff7f2

Browse files
committed
add helpers is_source and is_sink
1 parent 9a1e471 commit 80ff7f2

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/simplification.jl

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11

22
#adapted from osmnx: https://github.com/gboeing/osmnx/blob/main/osmnx/simplification.py
3+
"""
4+
Predicate wether v is source node in g
5+
"""
6+
is_source(g::AbstractGraph, v) = outdegree(g, v) == 0
7+
8+
"""
9+
Predicate wether v is sink node in g
10+
"""
11+
is_sink(g::AbstractGraph, v) = indegree(g, v) == 0
12+
313

414
"""
515
Predicate wether v is an edge endpoint in the simplified version of g
616
"""
717
function is_endpoint(g::AbstractGraph, v)
818
neighbors = all_neighbors(g, v)
9-
if v in neighbors # has self loop
19+
if is_source(g, v) || is_sink(g, v)
1020
return true
11-
elseif outdegree(g, v) == 0 || indegree(g, v) == 0 # sink or source
21+
elseif v in neighbors # has self loop
1222
return true
1323
elseif length(neighbors) != 2 || indegree(g, v) != outdegree(g, v) # change to/from one way
1424
return true

0 commit comments

Comments
 (0)