Skip to content

Implementation of DDA algorithm for finding maximal degree-based quasi-cliques using Gonum graph representation.

License

Notifications You must be signed in to change notification settings

nskondratev/gonum-quasi-clique

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gonum-quasi-clique

Implementation of algorithms for finding a.k.a. "quasi-cliques" (relaxation of clique) for Gonum graph representation.

Implemented algorithms

Prerequisites

  • Go v1.13 (tested only with this version)

Some algorithms require external solver to be installed (e.g. DDA), currently only the following solvers are supported:

Example

DDA

package main

import (
	"fmt"

	"gonum.org/v1/gonum/graph"
	"gonum.org/v1/gonum/graph/simple"
	
	"github.com/nskondratev/gonum-quasi-clique/dda"
	"github.com/nskondratev/gonum-quasi-clique/dda/solvers/glpk"
)

func main() {
	// Create simple graph with 6 vertices and 10 edges
	g := simple.NewUndirectedGraph()

	// Add nodes
	for i := 0; i < 6; i++ {
		g.AddNode(simple.Node(i))
	}

	// Add edges
	g.SetEdge(simple.Edge{F: simple.Node(0), T: simple.Node(1)})
	g.SetEdge(simple.Edge{F: simple.Node(0), T: simple.Node(3)})
	g.SetEdge(simple.Edge{F: simple.Node(0), T: simple.Node(4)})
	g.SetEdge(simple.Edge{F: simple.Node(0), T: simple.Node(5)})
	g.SetEdge(simple.Edge{F: simple.Node(1), T: simple.Node(2)})
	g.SetEdge(simple.Edge{F: simple.Node(1), T: simple.Node(3)})
	g.SetEdge(simple.Edge{F: simple.Node(1), T: simple.Node(4)})
	g.SetEdge(simple.Edge{F: simple.Node(2), T: simple.Node(3)})
	g.SetEdge(simple.Edge{F: simple.Node(3), T: simple.Node(4)})
	g.SetEdge(simple.Edge{F: simple.Node(4), T: simple.Node(5)})

	// Set up DDA options
	ddaOpts := dda.Opts{
		InputGraph: g,
		Gamma:      0.5,
		// You can also specify dda.AllSolutions to get all maximal quasi-cliques
		SolveMode:  dda.OneSolution,
		YQCKSolver: glpk.Solve,
	}

	// Find solutions
	_, quasiCliqueSize, err := dda.DDA(ddaOpts)
	if err != nil {
		panic(err) // Just for example
	}
	fmt.Printf("Quasi-clique size: %d\n", quasiCliqueSize) // Output: Quasi-clique size: 5
}

About

Implementation of DDA algorithm for finding maximal degree-based quasi-cliques using Gonum graph representation.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages