<commit_before>package model.graphs;

import java.util.*;
import java.util.Map.Entry;

/**
 * Created by stefanoandriolo on 19/04/17.
 */
public class Graph<T extends Comparable<T>> implements IGraph<T> {

    HashMap<Node<T>, LinkedList<Node<T>>> vertexes;


    public Graph() {
        this.vertexes = new HashMap<>();
    }

    @Override
    public boolean insertNode(Node<T> u) {

        if (!this.vertexes.containsKey(u)) {
            this.vertexes.put(u, new LinkedList<>());
            return true;
        }

        return false;
    }

    @Override
    public void deleteNode(Node<T> u) {
        // TODO: completare, cancellare il nodo e tutti gli archi adiacenti e incidenti
    }

    @Override
    // NOTA: Assumiamo che u e v esistano nel grafo
    public boolean insertEdge(Node<T> u, Node<T> v) {
        if (this.vertexes.containsKey(u) && this.vertexes.containsKey(v)) {
            this.vertexes.get(u).add(v);
            return true;
        }
        
        return false;
    }

    @Override
    public void deleteEdge(Node<T> u, Node<T> v) {
        if (this.vertexes.containsKey(u) && this.vertexes.containsKey(v))
            this.vertexes.get(u).remove(v);
    }

    @Override
    public Set<Node<T>> adj(Node<T> u) {

        HashSet<Node<T>> adjSet = new HashSet<Node<T>>();

        if (this.vertexes.containsKey(u))
            adjSet.addAll(this.vertexes.get(u));

        return adjSet;
    }

    @Override
    public Set<Node<T>> V() {
        return null;
    }

    @Override
    public void print() {
        for (Entry<Node<T>, LinkedList<Node<T>>> e :
                this.vertexes.entrySet()) {
            System.out.print(e.getKey() + " : ");<commit_msg>Update Graph.java<commit_after>package model.graphs;

import java.util.*;
import java.util.Map.Entry;

/**
 * Created by stefanoandriolo on 19/04/17.
 */
public class Graph<T extends Comparable<T>> implements IGraph<T> {

    HashMap<Node<T>, LinkedList<Node<T>>> vertexes;


    public Graph() {
        this.vertexes = new HashMap<>();
    }

    @Override
    public boolean insertNode(Node<T> u) {

        if (!this.vertexes.containsKey(u)) {
            this.vertexes.put(u, new LinkedList<>());
            return true;
        }

        return false;
    }

    @Override
	//TODO: cancellare u
	public void deleteNode(Node<T> u) {
		
		//cancello gli archi uscenti da u
		if (this.vertexes.containsKey(u)) {
			this.vertexes.get(u).clear() ;
			
			//cancello gli archi incidenti in u
			for (Node<T> n : this.vertexes.keySet()) {
				
				if (this.vertexes.get(n).contains(u))
					this.vertexes.get(n).remove(u) ;
							
			}
			
		}
		
	}

    @Override
    // NOTA: Assumiamo che u e v esistano nel grafo
    public boolean insertEdge(Node<T> u, Node<T> v) {
        if (this.vertexes.containsKey(u) && this.vertexes.containsKey(v)) {
            this.vertexes.get(u).add(v);
            return true;
        }
        
        return false;
    }

    @Override
    public void deleteEdge(Node<T> u, Node<T> v) {
        if (this.vertexes.containsKey(u) && this.vertexes.containsKey(v))
            this.vertexes.get(u).remove(v);
    }

    @Override
    public Set<Node<T>> adj(Node<T> u) {

        HashSet<Node<T>> adjSet = new HashSet<Node<T>>();

        if (this.vertexes.containsKey(u))
            adjSet.addAll(this.vertexes.get(u));

        return adjSet;
    }

    @Override
	public Set<Node<T>> V() {
		
		Set<Node<T>> nodeSet = new TreeSet<Node<T>>() ;
		
		if (!this.vertexes.isEmpty()) {
			nodeSet = this.vertexes.keySet() ;
		}
		
		return nodeSet;
	}

    @Override
    public void print() {
        for (Entry<Node<T>, LinkedList<Node<T>>> e :
                this.vertexes.entrySet()) {
            System.out.print(e.getKey() + " : ");
{'fraction_non_alphanumeric': 0.14519968262364455, 'fraction_numerical': 0.003173763554615181, 'mean_word_length': 2.2159863945578233, 'pattern_counts': {'":': 0, '<': 64, '<?xml version=': 0, '>': 64, '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': '6584169', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1265, 'n_words': 266}