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

"""

import networkx as nx
import packages.primitive as primitive
import math

class RelationGraph(object):
    def __init__(self,primArray, assignArray, angles = [], tolInDegr = 5.):
        self.G=nx.Graph()
        self.indexedPrimArray = {}
        
        # First create the nodes
        for p in primArray:
            self.G.add_node(p.uid, w=0)
            self.indexedPrimArray[p.uid] = p
            
        useAngles = len(angles) != 0
        
        # Then their relations
        for idx1, p1 in enumerate(primArray):
            for idx2, p2 in enumerate(primArray):
                if (idx2 > idx1):
                
                    if useAngles:
                        matched = False
                        angle = p1.angleInDegree(p2)
                        for a in angles:
                            if abs(a-angle) <= tolInDegr:
                                matched = True
                                break
                    
                        if matched: 
                            self.G.add_edge(p1.uid, p2.uid)<commit_msg>store ids as node parameters<commit_after>"""@package Primitive
This module provides an abstraction of the relationGraph using networkX

"""

import networkx as nx
import packages.primitive as primitive
import math

class RelationGraph(object):
    def __init__(self,primArray, assignArray, angles = [], tolInDegr = 5.):
        self.G=nx.Graph()
        self.indexedPrimArray = {}
        
        # First create the nodes
        for p in primArray:
            self.G.add_node(p.uid, w=0, uid=p.uid, did = p.did)
            self.indexedPrimArray[p.uid] = p
            
        useAngles = len(angles) != 0
        
        # Then their relations
        for idx1, p1 in enumerate(primArray):
            for idx2, p2 in enumerate(primArray):
                if (idx2 > idx1):
                
                    if useAngles:
                        matched = False
                        angle = p1.angleInDegree(p2)
                        for a in angles:
                            if abs(a-angle) <= tolInDegr:
                                matched = True
                                break
                    
                        if matched: 
                            self.G.add_edge(p1.uid, p2.uid)
{'fraction_non_alphanumeric': 0.0762536261914629, 'fraction_numerical': 0.01077496891835889, 'mean_word_length': 1.233117483811286, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4211320', 'n_tokens_mistral': 659, 'n_tokens_neox': 623, 'n_words': 172}