FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-dijkstra/draw_graph.py at master · crixodia/python-dijkstra · GitHub
crixodia
/
python-dijkstra
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
9
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-dijkstra
/
draw_graph.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (25 loc) · 881 Bytes
Breadcrumbs
python-dijkstra
/
draw_graph.py
Copy path
File metadata and controls
32 lines (25 loc) · 881 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
# Author: Cristian Bastidas
# GitHub: https://github.com/crixodia
# Date: 2020-10-7
from
graphviz
import
Graph
def
undirected_graph
(
wmat
,
name
=
"weighted_undirected_graph"
):
"""
Creates a pdf file with a weigthted graph's visualization
You must have installed graphviz (Python conector and OS compilation)
OS: https://www.graphviz.org/
Python module: https://graphviz.readthedocs.io/en/stable/index.html
Args:
wmat -- weigthted graph's adjacency matrix
name -- (optional) graph's filename
"""
n
=
len
(
wmat
)
f
=
Graph
(
name
,
filename
=
name
+
'.gv'
)
f
.
attr
(
'node'
,
shape
=
'circle'
)
for
i
in
range
(
n
):
f
.
node
(
str
(
i
))
for
i
in
range
(
n
):
for
j
in
range
(
n
):
if
wmat
[
i
][
j
]
!=
0
and
i
<
j
:
f
.
edge
(
str
(
i
),
str
(
j
),
label
=
str
(
wmat
[
i
][
j
]))
return
f
.
view
()
Back
|
FazBrowse Home
|
New Git URL