-
Notifications
You must be signed in to change notification settings - Fork 0
/
type.go
119 lines (94 loc) · 2.41 KB
/
type.go
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
// Copyright 2014, Hǎiliàng Wáng. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gexf
import (
"encoding/xml"
)
const (
Version = "1.2"
Namespace = "http://www.gexf.net/1.2draft"
TimeFormat = "2006-01-02+15:04"
DefaultCreator = "Gexf Go Library " + Version
)
type Gexf struct {
XMLName xml.Name
Version string `xml:"version,attr"`
Meta Meta `xml:"meta"`
Graph Graph `xml:"graph"`
}
type Graph struct {
Type GraphType `xml:"type,attr"`
IdType IdType `xml:"idtype,attr"`
EdgeType EdgeType `xml:"defaultedgetype,attr"`
Attributes Attributes `xml:"attributes,omitempty"`
Nodes Nodes `xml:"nodes"`
Edges Edges `xml:"edges"`
}
type EdgeType string
const (
Directed = EdgeType("directed")
Undirected = EdgeType("undirected")
Mutual = EdgeType("mutual")
DefaultEdgeType = Directed
)
type IdType string
const (
String = IdType("string")
Integer = IdType("integer")
DefaultIdType = String
)
type GraphType string
const (
Static = GraphType("static")
Dynamic = GraphType("dynamic")
DefaultGraphType = Static
)
type Meta struct {
LastModified string `xml:"lastmodifieddate,attr"`
Creator string `xml:"creator,omitempty"`
Keywords string `xml:"keywords,omitempty"`
Description string `xml:"description,omitempty"`
}
type ClassType string
const (
ClassNode = ClassType("node")
ClassEdge = ClassType("edge")
DefaultClassType = ClassNode
)
type Attributes struct {
Class ClassType `xml:"class,attr"`
Attribute []Attribute `xml:"attribute"`
}
type Attribute struct {
Id string `xml:"id,attr"`
Type string `xml:"type,attr"`
Title string `xml:"title,attr"`
Default string `xml:",innerxml"`
}
type Nodes struct {
Node []Node `xml:"node"`
Count int `xml:"count,attr"`
}
type Node struct {
Id string `xml:"id,attr"`
Label string `xml:"label,attr"`
AttValues AttValues `xml:"attvalues"`
}
type AttValues struct {
AttValue []AttValue `xml:"attvalue"`
}
type AttValue struct {
For string `xml:"for,attr"`
Value string `xml:"value,attr"`
}
type Edges struct {
Edge []Edge `xml:"edge"`
Count int `xml:"count,attr"`
}
type Edge struct {
Id string `xml:"id,attr"`
Source string `xml:"source,attr"`
Target string `xml:"target,attr"`
Weight float64 `xml:"weight,attr"`
}