mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 02:36:57 -07:00
new: exposing the graph object to js
This commit is contained in:
parent
0042b77c36
commit
93b7e7f2ed
8 changed files with 48 additions and 13 deletions
|
@ -10,6 +10,8 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var Loaded = (* Graph)(nil)
|
||||
|
||||
type NodeCallback func(*Node)
|
||||
type EdgeCallback func(*Node, []Edge, *Node)
|
||||
|
||||
|
@ -24,10 +26,11 @@ func NewGraph(path string) (*Graph, error) {
|
|||
if edges, err := LoadEdges(path); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return &Graph{
|
||||
Loaded = &Graph{
|
||||
path: path,
|
||||
edges: edges,
|
||||
}, nil
|
||||
}
|
||||
return Loaded, nil
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,6 +150,10 @@ func (g *Graph) Traverse(root string, onNode NodeCallback, onEdge EdgeCallback)
|
|||
return nil
|
||||
}
|
||||
|
||||
func (g *Graph) IsConnected(nodeType string, nodeID string) bool {
|
||||
return g.edges.IsConnected(fmt.Sprintf("%s_%s", nodeType, nodeID))
|
||||
}
|
||||
|
||||
func (g *Graph) Dot(filter, layout, name string, disconnected bool) (string, int, int, error) {
|
||||
size := 0
|
||||
discarded := 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue