<commit_before>"""@package Primitive
This module provides an abstraction of the relationGraph using networkX

"""

import networkx as nx
import packages.primitive as primitive

class RelationGraph(object):
    def __init__(self,primArray, assignArray):
        self.G=nx.Graph()
        
        # First create the nodes
        for p in primArray:
            self.G.add_node(p.uid, w=0)
        
        # Then their relations
        for idx1, p1 in enumerate(primArray):
            for idx2, p2 in enumerate(primArray):
                if (idx2 > idx1):           
                    self.G.add_edge(p1.uid, p2.uid)
        
        # And finaly the node weights (number of samples)
        # assignArray[][0] = point id
        # assignArray[][0] = primitive uid
        for a in assignArray:
            self.G.node[a[1]]['w'] += 1
                    
        print "Number of primitives:  ",self.G.number_of_nodes()
        print "Number of connections: ",self.G.number_of_edges()
        
    def draw(self):
        nx.draw_spectral(self.G)
        #nx.draw_networkx_labels(self.G,pos=nx.spectral_layout(self.G))<commit_msg>remove prints<commit_after>"""@package Primitive
This module provides an abstraction of the relationGraph using networkX

"""

import networkx as nx
import packages.primitive as primitive

class RelationGraph(object):
    def __init__(self,primArray, assignArray):
        self.G=nx.Graph()
        
        # First create the nodes
        for p in primArray:
            self.G.add_node(p.uid, w=0)
        
        # Then their relations
        for idx1, p1 in enumerate(primArray):
            for idx2, p2 in enumerate(primArray):
                if (idx2 > idx1):           
                    self.G.add_edge(p1.uid, p2.uid)
        
        # And finaly the node weights (number of samples)
        # assignArray[][0] = point id
        # assignArray[][0] = primitive uid
        for a in assignArray:
            self.G.node[a[1]]['w'] += 1
                    
        #print "Number of primitives:  ",self.G.number_of_nodes()
        #print "Number of connections: ",self.G.number_of_edges()
        
    def draw(self):
        nx.draw_spectral(self.G)
        #nx.draw_networkx_labels(self.G,pos=nx.spectral_layout(self.G))
{'fraction_non_alphanumeric': 0.10202286719437115, 'fraction_numerical': 0.011433597185576077, 'mean_word_length': 2.0252659574468086, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6798051', 'n_tokens_mistral': 700, 'n_tokens_neox': 679, 'n_words': 176}