<commit_before>package graph

import (
	"erx"
	"runtime"
	"strings"
)

type NodeId uint

type Nodes []NodeId

type Connection struct {
	Tail NodeId
	Head NodeId
}

type ConnectionsIterable interface {
	ConnectionsIter() <-chan Connection
}

type NodesIterable interface {
	NodesIter() <-chan NodeId
}

type GraphNodesWriter interface {
	// Adding single node to graph
	AddNode(node NodeId) erx.Error
}

type GraphNodesReader interface {
	// Getting nodes count in graph
	NodesCnt() int
}

type GraphNodesRemover interface {
	// Removing node from graph
	RemoveNode(node NodeId) erx.Error
}

type DirectedGraphArcsWriter interface {
	// Adding directed arc to graph
	AddArc(from, to NodeId) erx.Error
}

type DirectedGraphArcsRemover interface {
	// Removding directed arc
	RemoveArc(from, to NodeId) erx.Error
}

type DirectedGraphReader interface {
	// Getting arcs count in graph
	ArcsCnt() int

	// Getting all graph sources.
	GetSources() (Nodes, erx.Error)
	
	// Getting all graph sinks.
	GetSinks() (Nodes, erx.Error)
	
	// Getting node accessors
	GetAccessors(node NodeId) (Nodes, erx.Error)
	
	// Getting node predecessors
	GetPredecessors(node NodeId) (Nodes, erx.Error)
	
	// Checking arrow existance between node1 and node2
	//
	// node1 and node2 must exist in graph or error will be returned
	CheckArc(node1, node2 NodeId) (bool, erx.Error)
	
}

// Interface representing directed graph
type DirectedGraph interface {
	GraphNodesWriter
	GraphNodesReader
	GraphNodesRemover

	ConnectionsIterable
	NodesIterable
	DirectedGraphArcsWriter
	DirectedGraphArcsRemover
	DirectedGraphReader
}

type UndirectedGraphReader interface {
	// Arrows count in graph
	EdgesCnt() int

	// Checking edge existance between node1 and node2
	//
	// node1 and node2 must exist in graph or error will be returned
	CheckEdge(node1, node2 NodeId) (bool, erx.Error)

	// Getting all nodes, connected to given one
	GetNeighbours(node NodeId) (Nodes, erx.Error)
}

type UndirectedGraphEdgesWriter interface {
	// Adding new edge to graph
	AddEdge(node1, node2 NodeId) (erx.Error)	
}

type UndirectedGraphEdgesRemover interface {
	// Removing edge, connecting node1 and node2
	RemoveEdge(node1, node2 NodeId) erx.Error
}

// Interface representing undirected graph
type UndirectedGraph interface {
	GraphNodesWriter
	GraphNodesReader
	GraphNodesRemover

	ConnectionsIterable
	NodesIterable

	UndirectedGraphEdgesWriter
	UndirectedGraphEdgesRemover
	UndirectedGraphReader
}

type MixedGraph interface {
	GraphNodesWriter
	GraphNodesReader
	GraphNodesRemover
	
	ConnectionsIterable
	NodesIterable

	UndirectedGraphEdgesWriter
	UndirectedGraphEdgesRemover
	UndirectedGraphReader

	DirectedGraphArcsWriter
	DirectedGraphArcsRemover
	DirectedGraphReader
	
	EdgesIter() ConnectionsIterable
	ArcsIter() ConnectionsIterable
}

func init() {
	// adding to erx directory prefix to cut from file names
	_, file, _, _ := runtime.Caller(0)
	dirName := file[0:strings.LastIndex(file, "/")]
	prevDirName := dirName[0:strings.LastIndex(dirName, "/")+1]
	erx.AddPathCut(prevDirName)
}
<commit_msg>small change in MixedGraph interface<commit_after>package graph

import (
	"erx"
	"runtime"
	"strings"
)

type NodeId uint

type Nodes []NodeId

type Connection struct {
	Tail NodeId
	Head NodeId
}

type ConnectionsIterable interface {
	ConnectionsIter() <-chan Connection
}

type NodesIterable interface {
	NodesIter() <-chan NodeId
}

type GraphNodesWriter interface {
	// Adding single node to graph
	AddNode(node NodeId) erx.Error
}

type GraphNodesReader interface {
	// Getting nodes count in graph
	NodesCnt() int
}

type GraphNodesRemover interface {
	// Removing node from graph
	RemoveNode(node NodeId) erx.Error
}

type DirectedGraphArcsWriter interface {
	// Adding directed arc to graph
	AddArc(from, to NodeId) erx.Error
}

type DirectedGraphArcsRemover interface {
	// Removding directed arc
	RemoveArc(from, to NodeId) erx.Error
}

type DirectedGraphReader interface {
	// Getting arcs count in graph
	ArcsCnt() int

	// Getting all graph sources.
	GetSources() (Nodes, erx.Error)
	
	// Getting all graph sinks.
	GetSinks() (Nodes, erx.Error)
	
	// Getting node accessors
	GetAccessors(node NodeId) (Nodes, erx.Error)
	
	// Getting node predecessors
	GetPredecessors(node NodeId) (Nodes, erx.Error)
	
	// Checking arrow existance between node1 and node2
	//
	// node1 and node2 must exist in graph or error will be returned
	CheckArc(node1, node2 NodeId) (bool, erx.Error)
	
}

// Interface representing directed graph
type DirectedGraph interface {
	GraphNodesWriter
	GraphNodesReader
	GraphNodesRemover

	ConnectionsIterable
	NodesIterable
	DirectedGraphArcsWriter
	DirectedGraphArcsRemover
	DirectedGraphReader
}

type UndirectedGraphReader interface {
	// Arrows count in graph
	EdgesCnt() int

	// Checking edge existance between node1 and node2
	//
	// node1 and node2 must exist in graph or error will be returned
	CheckEdge(node1, node2 NodeId) (bool, erx.Error)

	// Getting all nodes, connected to given one
	GetNeighbours(node NodeId) (Nodes, erx.Error)
}

type UndirectedGraphEdgesWriter interface {
	// Adding new edge to graph
	AddEdge(node1, node2 NodeId) (erx.Error)	
}

type UndirectedGraphEdgesRemover interface {
	// Removing edge, connecting node1 and node2
	RemoveEdge(node1, node2 NodeId) erx.Error
}

// Interface representing undirected graph
type UndirectedGraph interface {
	GraphNodesWriter
	GraphNodesReader
	GraphNodesRemover

	ConnectionsIterable
	NodesIterable

	UndirectedGraphEdgesWriter
	UndirectedGraphEdgesRemover
	UndirectedGraphReader
}

type MixedGraph interface {
	GraphNodesWriter
	GraphNodesReader
	GraphNodesRemover
	
	ConnectionsIterable
	NodesIterable

	UndirectedGraphEdgesWriter
	UndirectedGraphEdgesRemover
	UndirectedGraphReader

	DirectedGraphArcsWriter
	DirectedGraphArcsRemover
	DirectedGraphReader
	
	ConnectionsIterable
	
	// Iterate over only undirected edges
	EdgesIter() ConnectionsIterable
	
	// Iterate over only directed arcs
	ArcsIter() ConnectionsIterable
}

func init() {
	// adding to erx directory prefix to cut from file names
	_, file, _, _ := runtime.Caller(0)
	dirName := file[0:strings.LastIndex(file, "/")]
	prevDirName := dirName[0:strings.LastIndex(dirName, "/")+1]
	erx.AddPathCut(prevDirName)
}

{'fraction_non_alphanumeric': 0.07073131701072172, 'fraction_numerical': 0.0070411265802528405, 'mean_word_length': 4.686988171064604, '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': '4509632', 'n_tokens_mistral': 2060, 'n_tokens_neox': 1964, 'n_words': 581}