<commit_before>(function () {

    var width = 960,
        height = 200;


    function createGraph(container, options) {

        var graph = container.append("div"),
            svg = graph.append("svg"),

            chart = svg.append("g")
                .classed("graph", true);

        function setSVGSize() {
            svg.attr("width", width)
                .attr("height", height);
        }

        function setWidthHeight(container) {
            var $container = $(container.node());

            width = $container.width();
            height = $container.height();
        }

        setWidthHeight(container);
        setSVGSize();

//        createTooltip(graph);

//        options = options || {}

//        var currentPage = options.currentPage || 0,
//            itemsPerPage = options.itemsPerPage || 50;

        chart.datum({
//            currentPage: currentPage,
//            itemsPerPage: itemsPerPage,
            data: []
        });

        $(window).resize(function() {
            if ($(container.node()).filter(":hidden").length == 0) {
                setWidthHeight(container);
                setSVGSize();
//                updateGraph(container, chart.datum().data);
            }
        });

        return graph;


    }

    function selectGraph(container) {
        return container.select(".graph");
    }

    function updateGraph(container, data) {
        var graph = selectGraph(container);

        var color = d3.scale.category20();

        if (this.force) {
            this.force.stop();
        }

        this.force = d3.layout.force()
            .charge(-120)
            .linkDistance(30)
            .size([width, height]);

        var link = graph.selectAll(".link")
            .data(data.links, function(d) {return d.index});

        link.enter()
            .insert("line", ":first-child")
            .attr("class", "link")
            .style("stroke-width", function(d) { return Math.sqrt(d.value); });

        link.exit()
            .remove();

        var node = graph.selectAll(".node")
            .data(data.nodes, function(d) {return d.name});


        node.enter()
            .append("circle")
            .attr("class", "node")
            .attr("r", 5)
            .style("fill", function(d) { return color(d.group); })
            .on("click", function(data) {
                if (d3.event.defaultPrevented) return;
                $(graph.node()).trigger("nodeClick", data);
            })
            .call(this.force.drag)
            .append("title")
            .text(function(d) { return d.name; });

        node.exit()
            .remove();

        this.force
            .nodes(data.nodes)
            .links(data.links)
            .start()
            .stop();

        this.force.on("tick", function() {
            link.attr("x1", function(d) { return d.source.x; })
                .attr("y1", function(d) { return d.source.y; })
                .attr("x2", function(d) { return d.target.x; })
                .attr("y2", function(d) { return d.target.y; });

            node.attr("transform", function(d) {
                return "translate(" + d.x + ", " + d.y + ")";
            });
//                .attr("transform", function(d) { return d.y; });

        });
    }

    function Graph(container, data, options) {
        this.container = createGraph(container, options);
        this.data = null;
        this.force = null;

        this.graph = selectGraph(this.container);

        var $me = $(this);

        $(this.graph.node()).on("nodeClick", function(event, data) {
            var ip = data.name;
            $me.trigger("click", NCI.model.getEndpointByIp(ip));
        });


        this.setData(data);
    }

    Graph.prototype.stop = function() {
        this.force.stop();
    };

    Graph.prototype.resume = function() {
        this.force.resume();
    };

    Graph.prototype.setData = function(data) {
        this.data = buildGraphData(data);
        this._update();
    };

    Graph.prototype.updateGraph = updateGraph;

    Graph.prototype._update = function() {
        this.updateGraph(this.container, this.data);
    };

    Graph.prototype.remove = function() {
        if (this.container) {
            this.container.on(".click");
            this.container.remove();
        }
        if (this.force) {
            this.force.stop();
            this.force = null;
        }
        this.graph = null;
        this.container = null;
    };

    function buildGraphData(data) {
        var nodes = [],
            links = [],
            indexMap = {};

        data.forEach(function (endpoint, index) {
            indexMap[endpoint.ip] = index;
            nodes.push({
                name: endpoint.ip,
                group: endpoint.activity.index
            });
        });

        data.forEach(function (endpoint) {
            var sourceIndex = indexMap[endpoint.ip];
            Object.keys(endpoint.connections).forEach(function (ip) {<commit_msg>Issues with server limitation issues fixed<commit_after>(function () {

    var width = 960,
        height = 200;


    function createGraph(container, options) {

        var graph = container.append("div"),
            svg = graph.append("svg"),

            chart = svg.append("g")
                .classed("graph", true);

        function setSVGSize() {
            svg.attr("width", width)
                .attr("height", height);
        }

        function setWidthHeight(container) {
            var $container = $(container.node());

            width = $container.width();
            height = $container.height();
        }

        setWidthHeight(container);
        setSVGSize();

//        createTooltip(graph);

//        options = options || {}

//        var currentPage = options.currentPage || 0,
//            itemsPerPage = options.itemsPerPage || 50;

        chart.datum({
//            currentPage: currentPage,
//            itemsPerPage: itemsPerPage,
            data: []
        });

        $(window).resize(function() {
            if ($(container.node()).filter(":hidden").length == 0) {
                setWidthHeight(container);
                setSVGSize();
//                updateGraph(container, chart.datum().data);
            }
        });

        return graph;


    }

    function selectGraph(container) {
        return container.select(".graph");
    }

    function updateGraph(container, data) {
        var graph = selectGraph(container);

        var color = d3.scale.category20();

        if (this.force) {
            this.force.stop();
        }

        this.force = d3.layout.force()
            .charge(-120)
            .linkDistance(30)
            .size([width, height]);

        var link = graph.selectAll(".link")
            .data(data.links, function(d) {return d.index});

        link.enter()
            .insert("line", ":first-child")
            .attr("class", "link")
            .style("stroke-width", function(d) { return Math.sqrt(d.value); });

        link.exit()
            .remove();

        var node = graph.selectAll(".node")
            .data(data.nodes, function(d) {return d.name});


        node.enter()
            .append("circle")
            .attr("class", "node")
            .attr("r", 5)
            .style("fill", function(d) { return color(d.group); })
            .on("click", function(data) {
                if (d3.event.defaultPrevented) return;
                $(graph.node()).trigger("nodeClick", data);
            })
            .call(this.force.drag)
            .append("title")
            .text(function(d) { return d.name; });

        node.exit()
            .remove();

        this.force
            .nodes(data.nodes)
            .links(data.links)
            .start()
            .stop();

        this.force.on("tick", function() {
            link.attr("x1", function(d) { return d.source.x; })
                .attr("y1", function(d) { return d.source.y; })
                .attr("x2", function(d) { return d.target.x; })
                .attr("y2", function(d) { return d.target.y; });

            node.attr("transform", function(d) {
                return "translate(" + d.x + ", " + d.y + ")";
            });
//                .attr("transform", function(d) { return d.y; });

        });
    }

    function Graph(container, data, options) {
        this.container = createGraph(container, options);
        this.data = null;
        this.force = null;

        this.graph = selectGraph(this.container);

        var $me = $(this);

        $(this.graph.node()).on("nodeClick", function(event, data) {
            var ip = data.name;
            $me.trigger("click", NCI.model.getEndpointByIp(ip));
        });


        this.setData(data);
    }

    Graph.prototype.stop = function() {
        this.force.stop();
    };

    Graph.prototype.resume = function() {
        this.force.resume();
    };

    Graph.prototype.setData = function(data) {
        this.data = buildGraphData(data);
        this._update();
    };

    Graph.prototype.updateGraph = updateGraph;

    Graph.prototype._update = function() {
        this.updateGraph(this.container, this.data);
    };

    Graph.prototype.remove = function() {
        if (this.container) {
            this.container.on(".click");
            this.container.remove();
        }
        if (this.force) {
            this.force.stop();
            this.force = null;
        }
        this.graph = null;
        this.container = null;
    };

    function buildGraphData(data) {
        var nodes = [],
            links = [],
            indexMap = {};

        data.forEach(function (endpoint, index) {
            indexMap[endpoint.ip] = index;
            nodes.push({
                name: endpoint.ip,
                group: endpoint.activity ? endpoint.activity.index : 0
            });
        });

        data.forEach(function (endpoint) {
            var sourceIndex = indexMap[endpoint.ip];
            Object.keys(endpoint.connections).forEach(function (ip) {
{'fraction_non_alphanumeric': 0.15279848891539916, 'fraction_numerical': 0.005070086489710707, 'mean_word_length': 1.5801487560913055, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4223473', 'n_tokens_mistral': 2870, 'n_tokens_neox': 2720, 'n_words': 497}