function CommunityStructure(graph, useWeight) {

    //this.graph = graph;
    this.N = graph.getNodesCount();
    this.graphWeightSum = 0;
    this.structure = this;

    /** @type {Map.<Number, Community>} */
    this.invMap = new Map();

    /** @type {Array.< Map.<Community, Number> >} */
    this.nodeConnectionsWeight = new Array(this.N);

    /** @type {Array.< Map.<Community, Number> >} */
    this.nodeConnectionsCount = new Array(this.N);

    /** @type {Array.<Community>} */
    this.nodeCommunities = new Array(this.N);

    /** @type {Map.<Node, Number>} */
    this.map = new Map();

    /** @type {Array.< Array.<ModEdge> >} */
    this.topology = new Array(this.N);
    for (var i = 0; i < this.N; i++) this.topology[i] = [];

    /** @type {Array.<Community>} */
    this.communities = [];

    /**@type {Array.<Number>} */
    this.weights = new Array(this.N);

    var index = 0;

    graph.forEachNode(function (node) {

        this.map.set(node.id, index);
        this.nodeCommunities[index] = new Community(this);
        this.nodeConnectionsWeight[index] = new Map();
        this.nodeConnectionsCount[index] = new Map();
        this.weights[index] = 0;
        this.nodeCommunities[index].seed(index);
        var hidden = new Community(this);
        hidden.nodes.add(index);
        this.invMap.set(index, hidden);
        this.communities.push(this.nodeCommunities[index]);
        index++;

    }.bind(this));


    graph.forEachLink(function (link) {

        var node_index = this.map.get(link.fromId)
            , neighbor_index = this.map.get(link.toId)
            , weight = 1
            ;

        if (node_index === neighbor_index) {
            return;
        }

        if (useWeight) {
            weight = link.data.weight;
        }

        this.setUpLink(node_index, neighbor_index, weight);
        this.setUpLink(neighbor_index, node_index, weight);


    }.bind(this));


    this.graphWeightSum /= 2.0;
}
@param {IGraph} graph
@param useWeight
@param {CommunityStructure} structure
@constructor