Skip to content

Graphdeppicker implements a weight-based probability picker which chooses dependencies on a graph.

License

Notifications You must be signed in to change notification settings

barbosaigor/graphdeppicker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Graphdeppicker

Graphdeppicker implements an algorithm that picks dependencies from a dependency graph, taking into account the probability of each node.

The algorithm is performed in two main steps. First, the algorithm chooses K nodes, then it picks N dependencies on those nodes. Heavy nodes are more likely to be chosen.

Documentation

Pick gets a graph with the maximum amount of nodes that can be picked. The algorithm randomly chooses the nodes, taking into account the weight of each node, and returns a set of nodes.

Node Weight Dependency
A 4 C
B 5 E, F
C 6 A, B, D
D 7 -
E 2 -
F 1 D, E
// First we have to create a dependency graph
g := graphll.New()
g.Add("a", 4, []string{"c"})
g.Add("b", 5, []string{"e", "f"})
g.Add("c", 6, []string{"a", "b", "d"})
g.Add("d", 7, nil)
g.Add("e", 2, nil)
g.Add("f", 1, []string{"d", "e"})

// Pick will execute the algorithm choosing up to three nodes
nodes, err := graphdeppicker.Pick(g, 3) // nodes could be ["c", "b", "d"]

About

Graphdeppicker implements a weight-based probability picker which chooses dependencies on a graph.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages