Documentation
¶
Index ¶
- type Edge
- func (edge *Edge) Disable()
- func (edge *Edge) Enable()
- func (edge *Edge) GetMaxWeight() float64
- func (edge *Edge) GetWeight() float64
- func (edge *Edge) IsDisabled() bool
- func (edge *Edge) IsEnabled() bool
- func (edge *Edge) ResetTempWeight0()
- func (edge *Edge) SetMaxWeight(weight float64)
- func (edge *Edge) SetTempWeight0()
- func (edge *Edge) SetWeight(weight float64)
- type Graph
- func (graph *Graph) AddEdge(from ID, to ID, localPort, localPortId, remotePort, remotePortId string, ...) error
- func (graph *Graph) AddVertex(id ID, name string) error
- func (graph *Graph) DeleteEdge(from ID, to ID) interface{}
- func (graph *Graph) DeleteEdgeByLocalPort(from ID, localPort string) *Edge
- func (graph *Graph) DeleteVertex(id ID) interface{}
- func (graph *Graph) Dijkstra(source ID) (dist map[ID]float64, prev map[ID]ID, err error)
- func (graph *Graph) DisableEdge(from, to ID)
- func (graph *Graph) DisablePath(path []ID)
- func (graph *Graph) DisableVertex(vertex ID)
- func (graph *Graph) EnableVertex(vertex ID)
- func (graph *Graph) GetAllEdges() map[ID]map[ID][]*Edge
- func (graph *Graph) GetAllVertices() map[ID]*vertex
- func (graph *Graph) GetEdge(from ID, to ID, localPort, remotePort string) (*Edge, error)
- func (graph *Graph) GetEdgeWeight(from ID, to ID) (float64, error)
- func (graph *Graph) GetEdges(from ID, to ID) ([]*Edge, error)
- func (graph *Graph) GetPathWeight(path []ID) (totalWeight float64)
- func (graph *Graph) GetVertex(id ID) (vertex *vertex, err error)
- func (graph *Graph) HasEdge(from ID, to ID, localPort, remotePort string) bool
- func (graph *Graph) HasVertex(id ID) bool
- func (graph *Graph) Kisp(source, destination ID, topK int) ([]float64, [][]ID, error)
- func (graph *Graph) Reset()
- type ID
- type Vertex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Edge ¶
type Edge struct {
TargetVerget *vertex
SourceVertex *vertex
LocalPort string // LocalPort is the port on THIS switch (vertex) that is connected to the OTHER switch
LocalPortID string // uuid of the localPort in TFC API
RemotePort string // RemotePort is the port on the OTHER switch that is connected to this switch.
RemotePortID string // uuid of the remotePort in TFC API
// contains filtered or unexported fields
}
func (*Edge) GetMaxWeight ¶
func (*Edge) IsDisabled ¶
func (*Edge) ResetTempWeight0 ¶
func (edge *Edge) ResetTempWeight0()
func (*Edge) SetMaxWeight ¶
func (*Edge) SetTempWeight0 ¶
func (edge *Edge) SetTempWeight0()
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph is made up of vertices and edges. Vertices in the graph must have an unique id. Each edges in the graph connects two vertices directed with a weight.
func (*Graph) AddEdge ¶
func (graph *Graph) AddEdge(from ID, to ID, localPort, localPortId, remotePort, remotePortId string, weight float64, maxWeight float64) error
AddEdge adds a new edge between the vertices by the input ids. Try to add an edge with -Inf weight will get an error. Try to add an edge from or to a vertex not in the graph will get an error. Try to add a duplicate edge will get an error.
func (*Graph) AddVertex ¶
AddVertex adds a new vertex into the graph. Try to add a duplicate vertex will get an error.
func (*Graph) DeleteEdge ¶
DeleteEdge deletes the edge between the vertices by the input id from the graph and gets the value of edge. Try to delete an edge from or to a vertex not in the graph will get an error. Try to delete an edge between disconnected vertices will get a nil.
func (*Graph) DeleteEdgeByLocalPort ¶
DeleteEdge deletes the edge between the vertices by the input id from the graph and gets the value of edge. Try to delete an edge from or to a vertex not in the graph will get an error. Try to delete an edge between disconnected vertices will get a nil.
func (*Graph) DeleteVertex ¶
DeleteVertex deletes a vertex from the graph and gets the value of the vertex. Try to delete a vertex not in the graph will get an nil.
func (*Graph) Dijkstra ¶
Dijkstra gets the shortest path from one vertex to all other vertices in the graph. https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
func (*Graph) DisableEdge ¶
DisableEdge disables the edge for further calculation.
func (*Graph) DisablePath ¶
DisablePath disables all the vertices in the path for further calculation.
func (*Graph) DisableVertex ¶
DisableVertex disables the vertex for further calculation.
func (*Graph) EnableVertex ¶
EnableVertex disables the vertex for further calculation.
func (*Graph) GetAllVertices ¶
func (*Graph) GetEdgeWeight ¶
GetEdgeWeight gets the weight of the edge between the two vertices by input ids. Try to get the weight of the edge from or to a vertex not in the graph will get an error. Try to get the weight of the edge between two disconnected vertices will get +Inf.
func (*Graph) GetEdges ¶
GetEdge gets the edge between the two vertices by input ids. Try to get the edge from or to a vertex not in the graph will get an error. Try to get the edge between two disconnected vertices will get an error.
func (*Graph) GetPathWeight ¶
GetPathWeight gets the total weight along the path by input ids. It will get -Inf if the input path is nil or empty. It will get -Inf if the path contains vertex not in the graph. It will get +Inf if the path contains vertices not connected.
func (*Graph) GetVertex ¶
GetVertex get a vertex by input id. Try to get a vertex not in the graph will get an error.
func (*Graph) HasVertex ¶
GetVertex get a vertex by input id. Try to get a vertex not in the graph will get an error.