<commit_before>
diam_focused = 80
diam_others = 60
links_distances = {
    "blood" : diam_focused * 2,
    undefined : diam_focused * 4
}


function layout()
{
    // var focused_id = window.anchor_params["id"];
    var focused_id = window.search_params_get["id"];
    var levels = parseInt(window.search_params_get["levels"]);
    if ( isNaN(levels) )
	levels = 1;

    function sizer(entity) { return (entity.id === focused_id ? diam_focused : diam_others) / 2; }

    var d3_nodes = [];
    var d3_links = [];
    var entity = get_entity_by_id(focused_id);

    function d3_node_exists(entity)
    {
	var i, n;
	for ( i = 0, n = d3_nodes.length; i < n; ++i )
	    if ( d3_nodes[i].entity === entity )
		return d3_nodes[i];
    }

    function d3_link_exists(entity0, entity1, link)
    {
	var i, n, cur;
	for ( i = 0, n = d3_links.length; i < n; ++i )
	{
	    cur = d3_links[i];
	    if ( cur.link.kind === link.kind
              && (cur.source.entity === entity0 && cur.target.entity === entity1)
               || (cur.source.entity === entity1 && cur.target.entity === entity0) )
	    {
		return true;
	    }
	}
	return false;
    }

    function import_neighbors(entity, levels)
    {
	if ( levels < 0 )
	    return;
	var found_node = d3_node_exists(entity);
	if ( found_node )
	    return found_node;

	// add entity
	var entity_node = entity.to_d3_node(sizer);

	// picture available? register pattern
	var pics = entity.pics, pic, pat_id, dim;
	if ( pics )
	{
	    pic = pics.split(",")[0];
	    pat_id = "pattern_" + entity.id;
	    dim = entity.id === focused_id ? diam_focused : diam_others;
	    defs.append("pattern")
		.attr("id", pat_id)
		.attr("width", "1")
		.attr("height", "1")
		.append("image")
		.attr("xlink:href", "Photos/" + pic)
		.attr("width", dim)
		.attr("height", dim);
	    entity_node.pattern_id = pat_id;
	}

	d3_nodes.push(entity_node);

	// add links, and neighbors
	var linksets = get_linksets_for_id(entity.id);
	var linkset, other, j, k, link, other_node, i, n;
	for ( i = 0, n = linksets.length; i < n; ++i )
	{
	    linkset = linksets[i];
	    other = get_entity_by_id(linkset.from === entity.id ? linkset.to : linkset.from);

	    // recurse add new neighbors
	    other_node = import_neighbors(other, levels - 1);

	    //
	    if ( other_node )
	    {
		for ( j = 0, k = linkset.links.length; j < k; ++j )
		{
		    link = linkset.links[j];
		    if ( ! d3_link_exists(entity, other, link) )
		    {
			d3_links.push({
			    source : entity_node,
			    target : other_node,
			    link : link,<commit_msg>Fill pattern rectangle with pic, slicing it as needed<commit_after>
diam_focused = 80
diam_others = 60
links_distances = {
    "blood" : diam_focused * 2,
    undefined : diam_focused * 4
}


function layout()
{
    // var focused_id = window.anchor_params["id"];
    var focused_id = window.search_params_get["id"];
    var levels = parseInt(window.search_params_get["levels"]);
    if ( isNaN(levels) )
	levels = 1;

    function sizer(entity) { return (entity.id === focused_id ? diam_focused : diam_others) / 2; }

    var d3_nodes = [];
    var d3_links = [];
    var entity = get_entity_by_id(focused_id);

    function d3_node_exists(entity)
    {
	var i, n;
	for ( i = 0, n = d3_nodes.length; i < n; ++i )
	    if ( d3_nodes[i].entity === entity )
		return d3_nodes[i];
    }

    function d3_link_exists(entity0, entity1, link)
    {
	var i, n, cur;
	for ( i = 0, n = d3_links.length; i < n; ++i )
	{
	    cur = d3_links[i];
	    if ( cur.link.kind === link.kind
              && (cur.source.entity === entity0 && cur.target.entity === entity1)
               || (cur.source.entity === entity1 && cur.target.entity === entity0) )
	    {
		return true;
	    }
	}
	return false;
    }

    function import_neighbors(entity, levels)
    {
	if ( levels < 0 )
	    return;
	var found_node = d3_node_exists(entity);
	if ( found_node )
	    return found_node;

	// add entity
	var entity_node = entity.to_d3_node(sizer);

	// picture available? register pattern
	var pics = entity.pics, pic, pat_id, dim;
	if ( pics )
	{
	    pic = pics.split(",")[0];
	    pat_id = "pattern_" + entity.id;
	    dim = entity.id === focused_id ? diam_focused : diam_others;
	    defs.append("pattern")
		.attr("id", pat_id)
		.attr("width", "1")
		.attr("height", "1")
		.append("image")
		.attr("xlink:href", "Photos/" + pic)
		.attr("preserveAspectRatio", "xMidYMid slice")
		.attr("width", dim)
		.attr("height", dim);
	    entity_node.pattern_id = pat_id;
	}

	d3_nodes.push(entity_node);

	// add links, and neighbors
	var linksets = get_linksets_for_id(entity.id);
	var linkset, other, j, k, link, other_node, i, n;
	for ( i = 0, n = linksets.length; i < n; ++i )
	{
	    linkset = linksets[i];
	    other = get_entity_by_id(linkset.from === entity.id ? linkset.to : linkset.from);

	    // recurse add new neighbors
	    other_node = import_neighbors(other, levels - 1);

	    //
	    if ( other_node )
	    {
		for ( j = 0, k = linkset.links.length; j < k; ++j )
		{
		    link = linkset.links[j];
		    if ( ! d3_link_exists(entity, other, link) )
		    {
			d3_links.push({
			    source : entity_node,
			    target : other_node,
			    link : link,
{'fraction_non_alphanumeric': 0.15099057511059819, 'fraction_numerical': 0.014233506443546836, 'mean_word_length': 2.7437005039596833, 'pattern_counts': {'":': 0, '<': 13, '<?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': '3983853', 'n_tokens_mistral': 2082, 'n_tokens_neox': 1899, 'n_words': 438}