Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
779af0e7
Commit
779af0e7
authored
Oct 14, 2014
by
Jeromy
Committed by
Juan Batiz-Benet
Oct 18, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add file i had forgotten to
parent
b2bd6848
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
diagnostics/vis.go
diagnostics/vis.go
+56
-0
No files found.
diagnostics/vis.go
0 → 100644
View file @
779af0e7
package
diagnostics
import
"encoding/json"
type
node
struct
{
Name
string
`json:"name"`
Value
uint64
`json:"value"`
}
type
link
struct
{
Source
int
`json:"source"`
Target
int
`json:"target"`
Value
int
`json:"value"`
}
func
GetGraphJson
(
dinfo
[]
*
DiagInfo
)
[]
byte
{
out
:=
make
(
map
[
string
]
interface
{})
names
:=
make
(
map
[
string
]
int
)
var
nodes
[]
*
node
for
_
,
di
:=
range
dinfo
{
names
[
di
.
ID
]
=
len
(
nodes
)
val
:=
di
.
BwIn
+
di
.
BwOut
nodes
=
append
(
nodes
,
&
node
{
Name
:
di
.
ID
,
Value
:
val
})
}
var
links
[]
*
link
linkexists
:=
make
([][]
bool
,
len
(
nodes
))
for
i
,
_
:=
range
linkexists
{
linkexists
[
i
]
=
make
([]
bool
,
len
(
nodes
))
}
for
_
,
di
:=
range
dinfo
{
myid
:=
names
[
di
.
ID
]
for
_
,
con
:=
range
di
.
Connections
{
thisid
:=
names
[
con
.
ID
]
if
!
linkexists
[
thisid
][
myid
]
{
links
=
append
(
links
,
&
link
{
Source
:
myid
,
Target
:
thisid
,
Value
:
3
,
})
linkexists
[
myid
][
thisid
]
=
true
}
}
}
out
[
"nodes"
]
=
nodes
out
[
"links"
]
=
links
b
,
err
:=
json
.
Marshal
(
out
)
if
err
!=
nil
{
panic
(
err
)
}
return
b
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment