File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 1
1
2
2
# 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
+
3
13
4
14
"""
5
15
Predicate wether v is an edge endpoint in the simplified version of g
6
16
"""
7
17
function is_endpoint (g:: AbstractGraph , v)
8
18
neighbors = all_neighbors (g, v)
9
- if v in neighbors # has self loop
19
+ if is_source (g, v) || is_sink (g, v)
10
20
return true
11
- elseif outdegree (g, v) == 0 || indegree (g, v) == 0 # sink or source
21
+ elseif v in neighbors # has self loop
12
22
return true
13
23
elseif length (neighbors) != 2 || indegree (g, v) != outdegree (g, v) # change to/from one way
14
24
return true
You can’t perform that action at this time.
0 commit comments