Debian Codegraph @

modules/graph/edge.go

raw symbols SCIP
1 package graph
2
3 import (
4 "fmt"
5 "github.com/bettercap/bettercap/session"
6 "time"
7 )
8
9 type EdgeType string
10
11 const (
12 Is EdgeType = "is"
13 ProbesFor EdgeType = "probes_for"
14 ProbedBy EdgeType = "probed_by"
15 ConnectsTo EdgeType = "connects_to"
16 Manages EdgeType = "manages"
17 )
18
19 type EdgeEvent struct {
20 Left *Node
21 Edge *Edge
22 Right *Node
23 }
24
25 type Edge struct {
26 Type EdgeType `json:"type"`
27 CreatedAt time.Time `json:"created_at"`
28 Position *session.GPS `json:"position,omitempty"`
29 }
30
31 func (e Edge) Dot(left, right *Node, width float64) string {
32 edgeLen := 1.0
33 if e.Type == Is {
34 edgeLen = 0.3
35 }
36 return fmt.Sprintf("\"%s\" -> \"%s\" [label=\"%s\", len=%.2f, penwidth=%.2f];",
37 left.String(),
38 right.String(),
39 e.Type,
40 edgeLen,
41 width)
42 }