Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Learning Python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Steinmann, Victor
Learning Python
Commits
9dab6caa
Commit
9dab6caa
authored
6 months ago
by
Steinmann
Browse files
Options
Downloads
Patches
Plain Diff
moved multiDi-Graph constructor into .py file
parent
f7db18a3
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
multiDiGraph.py
+37
-0
37 additions, 0 deletions
multiDiGraph.py
multiDiPath.ipynb
+7
-60
7 additions, 60 deletions
multiDiPath.ipynb
with
44 additions
and
60 deletions
multiDiGraph.py
0 → 100644
+
37
−
0
View file @
9dab6caa
import
matplotlib.pyplot
as
plt
import
networkx
as
nx
def
construct_graph
(
*
nodes
):
#erstelle einen leeren Graphen
graph
=
nx
.
MultiDiGraph
()
sizeA
=
1
for
arg
in
nodes
:
if
sizeA
<
len
(
arg
):
sizeA
=
len
(
arg
)
else
:
continue
#erstelle einen Knoten für alle Übergebenen Knoten
for
node
in
nodes
:
#für jeden String in den übergebenen Daten wird ein Knoten erstellt
if
isinstance
(
node
,
str
):
graph
.
add_node
(
node
)
#für jeden übergebenen touple der 2 knoten enthält wird eine Kante erstellt
elif
isinstance
(
node
,
tuple
)
and
len
(
node
)
==
2
:
if
isinstance
(
node
.
__getitem__
(
0
),
str
)
and
isinstance
(
node
.
__getitem__
(
1
),
str
):
graph
.
add_edge
(
node
.
__getitem__
(
0
),
node
.
__getitem__
(
1
))
else
:
print
(
'
Kante enthält unbekannten Knoten
'
)
else
:
print
(
'
Argument ist weder knoten noch Kante
'
)
continue
pos
=
nx
.
spring_layout
(
graph
)
#berechnung der Knotengröße entsprechend der Beschriftungs argumente
nx
.
draw_networkx_nodes
(
graph
,
pos
,
node_size
=
sizeA
*
325
,
node_color
=
'
white
'
,
edgecolors
=
'
black
'
,
linewidths
=
1
)
nx
.
draw_networkx_edges
(
graph
,
pos
,
edge_color
=
'
black
'
,
node_size
=
sizeA
*
275
,
arrowsize
=
20
)
nx
.
draw_networkx_labels
(
graph
,
pos
)
return
graph
\ No newline at end of file
This diff is collapsed.
Click to expand it.
multiDiPath.ipynb
+
7
−
60
View file @
9dab6caa
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