GithubHelp home page GithubHelp logo

adwitsingh / nodeinbetween Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 20 KB

Python application which returns all the nodes with highest Betweenness Centrality in a given undirected unweighted graph.

License: GNU General Public License v3.0

Python 100.00%

nodeinbetween's Introduction

NodeInBetween

Python application which returns all the nodes with highest Betweenness Centrality in a given undirected unweighted graph.

Betweenness centrality finds wide application in network theory apart from biology, transport and scientific cooperation: it represents the degree of which nodes stand between each other. For example, in a network, a node with higher betweenness centrality would have more control over the network, because more information will pass through that node. This is used extensively in social media analysis.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

This project needs python3 installed on the local machine along with re, itertools and ast, which can be installed using:

$ python3 -m pip install ast
$ python3 -m pip install re
$ python3 -m pip install itertools

Executing

SBC.py defines a class Graph which takes vertices and edges as arguments:

vertices: List of integers as vertices in the given graph.
edges: List of 2-element tuple as edges in the given graph.

The following methods are defined in the module:

  1. def min_dist(self, start_node, end_node):
    		"""
    		Finds minimum distance between start_node and end_node
    
    		Args:
    			start_node: Vertex to find distance from
    			end_node: Vertex to find distance to
    
    		Returns:
    			An integer denoting minimum distance between start_node
    			and end_node
    		"""
  2. def all_paths(self, node, destination, visited, dist):
    		"""
    		Finds all paths from node to destination with length = dist
    
    		Args:
    			node: Node to find path from
    			destination: Node to reach
    			visited: Nodes already visited. Prevents traceback in recursion
    			dist: Allowed distance of path
    		   
    		Returns:
    			List of path, where each path is list ending on destination
    
    			Returns None if there no paths
    		"""
  3. def all_shortest_paths(self, start_node, end_node):
    		"""
    		Finds all shortest paths between start_node and end_node
    
    		Args:
    			start_node: Starting node for paths
    			end_node: Destination node for paths
    
    		Returns:
    			A list of path, where each path is a list of integers.
    		"""
  4. def betweenness_centrality(self, node):
    		"""
    		Find betweenness centrality of the given node
    
    		Args:
    			node: Node to find betweenness centrality of.
    
    		Returns:
    			Single floating point number, denoting betweenness centrality
    			of the given node
    		"""
  5. def top_k_betweenness_centrality(self):
    		"""
    		Find top k nodes based on highest equal standard betweenness 				centrality.
    		
    		Returns:
    			List a integer, denoting top k nodes based on standard 						betweenness centrality.
    		"""

To run the module:

$ python3 SBC.py

Example

$ python3 SBC.py 
Enter list of vertices: [0,1,2,3,4]
Enter list of edges: [(0,1), (1,4), (1,2), (1,3), (3,4)]
Node(s) having top Betweenness Centrality ( 0.8333333333333333 ) = 1

Authors

nodeinbetween's People

Contributors

adwitsingh avatar

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.