Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Detection eddies
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IPSL
LMD
DPAO
Detection eddies
Commits
96e8df68
Commit
96e8df68
authored
4 years ago
by
Lionel GUEZ
Browse files
Options
Downloads
Patches
Plain Diff
Allow import of `report_graph`
For `read_eddy_graph`.
parent
a9687151
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Analysis/report_graph.py
+35
-33
35 additions, 33 deletions
Analysis/report_graph.py
with
35 additions
and
33 deletions
Analysis/report_graph.py
+
35
−
33
View file @
96e8df68
...
...
@@ -2,7 +2,6 @@
import
networkx
as
nx
import
csv
import
shapefile
def
read_eddy_graph
():
G
=
nx
.
DiGraph
()
...
...
@@ -21,46 +20,49 @@ def read_eddy_graph():
return
G
G
=
read_eddy_graph
()
print
(
"
Number of nodes:
"
,
len
(
G
))
print
(
"
Number of edges:
"
,
G
.
number_of_edges
())
n1
=
0
n2
=
0
print
(
"
Merging:
"
)
if
__name__
==
"
__main__
"
:
import
shapefile
for
n
,
d
in
G
.
in_degree
():
if
d
>=
1
:
n2
+=
1
if
d
>=
2
:
print
(
list
(
G
.
predecessors
(
n
)),
"
->
"
,
n
)
G
=
read_eddy_graph
()
print
(
"
Number of nodes:
"
,
len
(
G
))
print
(
"
Number of edges:
"
,
G
.
number_of_edges
())
n1
=
0
n2
=
0
print
(
"
Merging:
"
)
print
(
"
---
"
)
print
(
"
Splitting:
"
)
for
n
,
d
in
G
.
in_degree
():
if
d
>=
1
:
n2
+=
1
if
d
>=
2
:
print
(
list
(
G
.
predecessors
(
n
)),
"
->
"
,
n
)
for
n
,
d
in
G
.
out_degree
():
if
d
>=
1
:
n1
+=
1
if
d
>=
2
:
print
(
n
,
"
->
"
,
list
(
G
.
successors
(
n
)))
print
(
"
---
"
)
print
(
"
Splitting:
"
)
print
(
"
---
"
)
print
(
"
number of nodes with at least one successor =
"
,
n1
)
print
(
"
number of nodes with at least one predecessor =
"
,
n2
)
for
n
,
d
in
G
.
out_degree
():
if
d
>=
1
:
n1
+=
1
if
d
>=
2
:
print
(
n
,
"
->
"
,
list
(
G
.
successors
(
n
)))
my_subgraphs
=
{}
print
(
"
---
"
)
print
(
"
number of nodes with at least one successor =
"
,
n1
)
print
(
"
number of nodes with at least one predecessor =
"
,
n2
)
my_subgraphs
=
{}
for
n
in
G
:
if
n
[
0
]
not
in
my_subgraphs
:
my_subgraphs
[
n
[
0
]]
=
[]
my_subgraphs
[
n
[
0
]].
append
(
n
)
for
n
in
G
:
if
n
[
0
]
not
in
my_subgraphs
:
my_subgraphs
[
n
[
0
]]
=
[]
my_subgraphs
[
n
[
0
]].
append
(
n
)
A
=
nx
.
nx_agraph
.
to_agraph
(
G
)
A
=
nx
.
nx_agraph
.
to_agraph
(
G
)
for
k
,
s
in
my_subgraphs
.
items
():
A
.
add_subgraph
(
s
,
rank
=
"
same
"
)
for
k
,
s
in
my_subgraphs
.
items
():
A
.
add_subgraph
(
s
,
rank
=
"
same
"
)
sr
=
shapefile
.
Reader
(
"
SHP_triplet/extremum
"
)
sr
=
shapefile
.
Reader
(
"
SHP_triplet/extremum
"
)
for
rec
in
sr
.
iterRecords
():
n
=
A
.
get_node
((
rec
.
date_index
,
rec
.
eddy_index
))
n
.
attr
[
"
shape
"
]
=
"
box
"
for
rec
in
sr
.
iterRecords
():
n
=
A
.
get_node
((
rec
.
date_index
,
rec
.
eddy_index
))
n
.
attr
[
"
shape
"
]
=
"
box
"
A
.
write
(
"
eddy_graph.gv
"
)
print
(
'
Created file
"
eddy_graph.gv
"
.
'
)
A
.
write
(
"
eddy_graph.gv
"
)
print
(
'
Created file
"
eddy_graph.gv
"
.
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment