Code Monkey home page Code Monkey logo

kcol-graph's Introduction

kcol_graph_gen Downloads

Cover Logo

A minimalistic python package to generate a k-colorable graph.

Installation

Just run pip install kcol-graph-gen and you are good to go!

Usage

Before generating the graph you have to make an object of the class KColorableGraphGenerator. You can specify an optional seed for the default random package which is used during the generation of the graph.

Once the object is crated, you can use generate method to generate the graphs. This takes three arguments n : number of vertices, k : specifying the number of colors, p(optional, default=0.5) : Probability with which any edge is added into the graph. Higher the value of p denser the resulting graph will be.

Below is the code snippet which demonstrates the usage:

from kcol_graph_gen import KColorableGraphGenerator

generator = KColorableGraphGenerator(seed=42)
edges = generator.generate(4, 2, 0.3)  # Create a bipartite graph

print(edges)  # Printing the list of edges
# > [(2, 3), (2, 4), (1, 2)]

edges = generator.generate(
    6, 3, 0.9
)  # Create a 3-colorable dense graph with 6 vertices

print(edges)  # Printing the list of edges
# > [(2, 4), (1, 2), (3, 4), (1, 5), (2, 3), (4, 5), (2, 6), (5, 6), (3, 6), (2, 5), (1, 3)]

kcol-graph's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.