<commit_before>package concrete_test

import (
	"github.com/gonum/graph"
	"github.com/gonum/graph/concrete"
)

var _ graph.DirectedGraph = &concrete.DenseGraph{}
var _ graph.CrunchGraph = &concrete.DenseGraph{}<commit_msg>Added tests for dense graph<commit_after>package concrete_test

import (
	"github.com/gonum/graph"
	"github.com/gonum/graph/concrete"
	"testing"
)

var _ graph.DirectedGraph = &concrete.DenseGraph{}
var _ graph.CrunchGraph = &concrete.DenseGraph{}

func TestBasicDenseImpassable(t *testing.T) {
	dg := concrete.NewDenseGraph(5, false)
	if dg == nil {
		t.Fatal("Directed graph could not be made")
	}

	for i := 0; i < 5; i++ {
		if !dg.NodeExists(concrete.GonumNode(i)) {
			t.Errorf("Node that should exist doesn't: %d", i)
		}

		if neighbors := dg.Neighbors(concrete.GonumNode(i)); len(neighbors) != 0 {
			t.Errorf("Node in impassable graph has a neighbor. Node: %d Neighbors: %v", i, neighbors)
		}
	}

	for i := 5; i < 10; i++ {
		if dg.NodeExists(concrete.GonumNode(i)) {
			t.Errorf("Node exists that shouldn't: %d")
		}
	}
}

func TestBasicDensePassable(t *testing.T) {
	dg := concrete.NewDenseGraph(5, true)
	if dg == nil {
		t.Fatal("Directed graph could not be made")
	}

	for i := 0; i < 5; i++ {
		if !dg.NodeExists(concrete.GonumNode(i)) {
			t.Errorf("Node that should exist doesn't: %d", i)
		}

		if neighbors := dg.Neighbors(concrete.GonumNode(i)); len(neighbors) != 5 {
			t.Errorf("Node in passable graph doesn't have the right number of neighbors. Node: %d Neighbors: %v", i, neighbors)
		}
	}

	for i := 5; i < 10; i++ {
		if dg.NodeExists(concrete.GonumNode(i)) {
			t.Errorf("Node exists that shouldn't: %d")
		}
	}
}
{'fraction_non_alphanumeric': 0.15564903846153846, 'fraction_numerical': 0.008413461538461538, 'mean_word_length': 4.0, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2104360', 'n_tokens_mistral': 710, 'n_tokens_neox': 648, 'n_words': 152}