<commit_before># Alchemy.js is a graph drawing application for the web.
# Copyright (C) 2014  GraphAlchemist, Inc.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

class alchemy.Layout
    constructor: ->
        conf = alchemy.conf
        @k = Math.sqrt(_.size(alchemy._nodes) / (conf.graphWidth() * conf.graphHeight()))
        @_clustering = new alchemy.clustering
        
        if conf.cluster
            @_charge = () -> @_clustering.layout.charge
        else
            @_charge = () -> -10 / @k

        if conf.cluster
            @_linkDistancefn = (edge) -> @_clustering.layout.linkDistancefn(edge)
        else if typeof conf.linkDistancefn is ('number' or 'string')
            @_linkDistancefn = (edge) -> conf.linkDistancefn
        else if typeof conf.linkDistancefn is 'function'
            conf.linkDistancefn(edge)

        if alchemy.conf.cluster
            @_linkStrength = (edge) -> @_clustering.layout.linkStrength(edge)
        else
            @_linkStrength = (edge) ->
                nodes = alchemy._nodes
                if nodes[edge.source.id].properties.root or nodes[edge.target.id].properties.root
                    0.5
                else
                    0.8

    gravity: () =>
        if alchemy.conf.cluster
            @_clustering.layout.gravity(@k)
        else
            100 * @k<commit_msg>fix layout constants for slightly better layout<commit_after># Alchemy.js is a graph drawing application for the web.
# Copyright (C) 2014  GraphAlchemist, Inc.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

class alchemy.Layout
    constructor: ->
        conf = alchemy.conf
        nodes = alchemy._nodes
        @k = Math.sqrt(Math.log(_.size(alchemy._nodes)) / (conf.graphWidth() * conf.graphHeight() ) )
        @_clustering = new alchemy.clustering
        
        if conf.cluster
            @_charge = () -> @_clustering.layout.charge
            @_linkStrength = (edge) -> @_clustering.layout.linkStrength(edge)

        else
            @_charge = () -> -10 / @k
            @_linkStrength = (edge) ->
                if nodes[edge.source.id].properties.root or nodes[edge.target.id].properties.root
                    1
                else
                    0.9

        if conf.cluster
            @_linkDistancefn = (edge) -> @_clustering.layout.linkDistancefn(edge)
        else if conf.linkDistancefn is 'default'
            @_linkDistancefn = (edge) -> 
                1 / (@k * 50)
        else if typeof conf.linkDistancefn is 'number'
            @_linkDistancefn = (edge) -> conf.linkDistancefn
        else if typeof conf.linkDistancefn is 'function'
            @_linkDistancefn = (edge) -> conf.linkDistancefn(edge)


    gravity: () =>
        if alchemy.conf.cluster
            @_clustering.layout.gravity(@k)
        else
            50 * @k
{'fraction_non_alphanumeric': 0.08958178668646374, 'fraction_numerical': 0.007176441474882455, 'mean_word_length': 2.2649434571890144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5921612', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1072, 'n_words': 380}