Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
# jLouvain

**Corneliu S.**

---
## Description

Formally, a community detection aims to partition a graph’s vertices in subsets, such that there are many edges connecting between vertices of the same sub-set compared to vertices of different sub-sets; in essence, a community has many more ties between each constituent part than with outsiders. There are numerous algorithms present in the literature for solving this problem, a complete survey can be found in [1]. One of the popular community detection algorithms is presented in [2]. This algorithm separates the network in communities by optimizing greedily a modularity score after trying various grouping operations on the network. By using this simple greedy approach the algorithm is computationally very efficient.
[1] Fortunato, Santo. "Community detection in graphs." Physics Reports 486, no. 3-5 (2010).
[2] V.D. Blondel, J.-L. Guillaume, R. Lambiotte, E. Lefebvre. "Fast unfolding of communities in large networks." J. Stat. Mech., 2008: 1008.
Formally, a community detection aims to partition a graph’s vertices in subsets, such that there are many edges connecting between vertices of the same sub-set compared to vertices of different sub-sets; in essence, a community has many more ties between each constituent part than with outsiders. There are numerous algorithms present in the literature for solving this problem, a complete survey can be found in [1].

##Usage
1. Import the script.
One of the popular community detection algorithms is presented in [2]. This algorithm separates the network in communities by optimizing greedily a modularity score after trying various grouping operations on the network. By using this simple greedy approach the algorithm is computationally very efficient.

[1] Fortunato, Santo. "Community detection in graphs." Physics Reports 486, no. 3-5 (2010).

[2] V.D. Blondel, J.-L. Guillaume, R. Lambiotte, E. Lefebvre. "Fast unfolding of communities in large networks." J. Stat. Mech., 2008: 1008.

## Usage
1. Import the script.
#### Client-side:
<script type="text/javascript" src="jLouvain.js"></script>

#### Or server-side (node.js):
var jLouvain = require('./jLouvain')

2. Sample Data Format
####Node Data
#### Node Data
var node_data = ['id1', 'id2', 'id3']; // any type of string can be used as id
####Edge Data
#### Edge Data
var edge_data = [{source: 'id1', target:'id2', weight: 10.0},
{source: 'id2', target:'id3', weight: 20.0},
{source: 'id3', target:'id1', weight: 30.0}];
####(Optional) Partition Data
#### (Optional) Partition Data
var init_part = {'id1':0, 'id2':0, 'id3': 1};
// Object with ids of nodes as properties and community number assigned as value.

3. Run the Algorithm on your node and edge set by chaining the **nodes** and **edges** methods, optionally you can provide an intermediary community partition assignement with the **partition_init** method. [ **Order of chaining is important** ]

var community = jLouvain().nodes(node_data).edges(edge_data).partition_init(init_part);
var result = community();##Example
var result = community();


## Example
See **example.html**, use the console to view the raw input data and raw output.

Initial input graph for community detection.
![](example/default.png)
####After Community Detection
We can see the partitioned graph vertices with the help of color coding.![](example/communities.png)

![](example/default.png)
#### After Community Detection
We can see the partitioned graph vertices with the help of color coding.
![](example/communities.png)
2 changes: 1 addition & 1 deletion example/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>jLouvain Example</title>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="//d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="../jLouvain.js"></script>


Expand Down
18 changes: 18 additions & 0 deletions example/serverSide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Example of jLouvain used from node.js

*/
var jLouvain = require('../jLouvain')

var node_data = ['id1', 'id2', 'id3', 'id4']
, edge_data = [
{source: 'id1', target:'id2', weight: 10.0}
, {source: 'id2', target:'id3', weight: 20.0}
, {source: 'id3', target:'id1', weight: 30.0}
]
, init_part = {'id1':0, 'id2':0, 'id3': 1}

var community = jLouvain().nodes(node_data).edges(edge_data).partition_init(init_part)
, result = community()

console.log('result is:', result)
23 changes: 20 additions & 3 deletions jLouvain.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,25 @@
Based on https://bitbucket.org/taynaud/python-louvain/overview

*/
(function () {
jLouvain = function () {
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.jLouvain = factory();
}
}(this, function () {

// Just return a value to define the module export.
// This example returns an object, but the module
// can return a function as the exported value.
return function () {
//Constants
var __PASS_MAX = -1;
var __MIN = 0.0000001;
Expand Down Expand Up @@ -397,4 +414,4 @@

return core;
}
})();
}));
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "jLouvain",
"version": "1.0.0",
"description": "**Corneliu S.**",
"main": "jLouvain.js",
"directories": {
"example": "example"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Mango-information-systems/jLouvain.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Mango-information-systems/jLouvain/issues"
},
"homepage": "https://github.com/Mango-information-systems/jLouvain#readme"
}