graph

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package graph contains all graphing algorithms used

the graph package contains all functions that relate to graphs such as the DFS implementation as well as the cycle resolution code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CyclicError

type CyclicError struct {
	// contains filtered or unexported fields
}

CyclicError is a custom error that is created when cycles are detected in the database schema

func (CyclicError) Error

func (e CyclicError) Error() string

Error returns a formatted string informing the user of all detected cycles in the database

type MissingTableError

type MissingTableError struct {
	// contains filtered or unexported fields
}

MissingTableError is a custom error that is created when a given table can not be found in the database

func (MissingTableError) Error

func (e MissingTableError) Error() string

Error returns a formated string that informs the user that the table does not exist in the database

type Ordering

type Ordering struct {
	// contains filtered or unexported fields
}

Ordering is a struct that contains the information necessary to detect and remove cycles

func NewOrdering

func NewOrdering(db *sql.DB) *Ordering

NewOrdering returns the address of a properly initiated Ordering struct

func (*Ordering) GetAndResolveCycles

func (tl *Ordering) GetAndResolveCycles()

GetAndResolveCycles immediately runs the suggestion queries instead of returning them unlike GetSuggestionQueries

func (*Ordering) GetCycles

func (tl *Ordering) GetCycles() []string

GetCycles uses DFS to detect cycles, all detected cycles are added to a linked list and returned

func (*Ordering) GetOrder

func (tl *Ordering) GetOrder(tableName string) ([]string, error)

GetOrder returns a list of table names that need entries before the given table can receive an entry alongside any errors that occur

func (*Ordering) GetSuggestionQueries

func (tl *Ordering) GetSuggestionQueries() []string

GetSuggestionQueries returns a list of queries necessary to remove found cycles in the database schema

func (*Ordering) Init

func (tl *Ordering) Init(db *sql.DB)

Init takes in a database connection and sets all private variables in the Ordering struct

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL