-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommom.jl
More file actions
119 lines (107 loc) · 2.28 KB
/
Commom.jl
File metadata and controls
119 lines (107 loc) · 2.28 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
module Commom
using GraphPlot
import Graphs: edges
using Graphs
using SimpleWeightedGraphs
export imprimir, desenhar, edge, edges
const ∞ = Inf
function imprimir(R, L, i, f⁺, f⁻, p, σ, y)
print("y: ")
display(y)
print("R: ")
display(R)
println()
print("L: ")
display(L)
println()
print("i: ")
display(i)
println()
print("f⁺: ")
display(f⁺)
println()
print("f⁻: ")
display(f⁻)
println()
print("p: ")
display(p)
println()
print("σ: ")
display(σ)
println()
end
function imprimir(R, Q, r, d, p, h)
print("R:")
println(R)
print("Q:")
println(Q)
print("r:")
println(r)
print("d:")
println(d)
print("p:")
println(p)
print("h:")
println(h)
println()
end
function imprimir(R, Q, r, d, p)
print("R:")
println(R)
print("Q:")
println(Q)
print("r:")
println(r)
print("d:")
println(d)
print("p:")
println(p)
println()
end
function imprimir(E, T, V)
print("T:")
println(T)
print("V:")
println(V)
print("E':")
println(E)
println()
end
function imprimir(d, p)
print("d:")
display(d)
print("p:")
display(p)
println()
end
function desenhar(w::Matrix{Int64} )
g = SimpleWeightedDiGraph(w)
arestas = edges(g)
pesos = [p.weight for p ∈ arestas]
gplot(g, edgelabel=pesos, nodelabel=1:nv(g), edgelabeldistx=0.5, edgelabeldisty=0.5)
end
function desenhar(g::AbstractSimpleWeightedGraph{Int64,Int64})
arestas = edges(g)
pesos = [p.weight for p ∈ arestas]
gplot(g, edgelabel=pesos, nodelabel=1:nv(g), edgelabeldistx=0.5, edgelabeldisty=0.5)
end
edges(g::AbstractSimpleWeightedGraph{Int64,Int64}, v::Int64) = [e for e ∈ edges(g) if src(e) == v]
function edge(g::SimpleWeightedGraph{Int64,Int64}, s, d)
for e ∈ edges(g)
if (dst(e) == d && src(e) == s)
return e
elseif (dst(e) == s && src(e) == d)
return SimpleWeightedEdge(s, d, e.weight)
end
end
return SimpleWeightedEdge(s, d, ∞)
end
function edge(g::SimpleWeightedDiGraph{Int64,Int64}, s, d)
for e ∈ edges(g)
if dst(e) == d && src(e) == s
return e
end
end
return SimpleWeightedEdge(s, d, ∞)
end
end