graph

package
v0.0.0-...-7253c86 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(a int) int

func AlienDictionary

func AlienDictionary(words []string) string

func CheapestFlightsWithinKStops

func CheapestFlightsWithinKStops(n int, flights [][]int, src int, dst int, k int) int

func CloneGraph

func CloneGraph(node *util.GraphNode) *util.GraphNode

func CourseSchedule

func CourseSchedule(numCourses int, prerequisites [][]int) bool

func CourseScheduleII

func CourseScheduleII(numCourses int, prerequisites [][]int) []int

func GraphValidTree

func GraphValidTree(n int, edges [][]int) bool

func MinCostToConnectAllPoints

func MinCostToConnectAllPoints(points [][]int) int

func NetworkDelayTime

func NetworkDelayTime(times [][]int, n int, k int) int

networkDelayTime calculates the time it will take for all nodes to receive a signal sent from a given node.

func ReconstructItinerary

func ReconstructItinerary(tickets [][]string) []string

func SwimInRisingWater

func SwimInRisingWater(grid [][]int) int

Types

type Edge

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

Edge represents a directed edge with a weight.

type ItineraryPriorityQueue

type ItineraryPriorityQueue []string

PriorityQueue implements a min-heap for strings to maintain lexical order

func (ItineraryPriorityQueue) Len

func (pq ItineraryPriorityQueue) Len() int

func (ItineraryPriorityQueue) Less

func (pq ItineraryPriorityQueue) Less(i, j int) bool

func (*ItineraryPriorityQueue) Pop

func (pq *ItineraryPriorityQueue) Pop() interface{}

func (*ItineraryPriorityQueue) Push

func (pq *ItineraryPriorityQueue) Push(x interface{})

func (ItineraryPriorityQueue) Swap

func (pq ItineraryPriorityQueue) Swap(i, j int)

type MinHeap

type MinHeap [][]int

MinHeap is a priority queue to store nodes and their cumulative distances from the start.

func (MinHeap) Len

func (h MinHeap) Len() int

func (MinHeap) Less

func (h MinHeap) Less(i, j int) bool

func (*MinHeap) Pop

func (h *MinHeap) Pop() interface{}

func (*MinHeap) Push

func (h *MinHeap) Push(x interface{})

func (MinHeap) Swap

func (h MinHeap) Swap(i, j int)

type PointsEdge

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

Edge represents an edge in the graph

type PriorityQueue

type PriorityQueue []*PointsEdge

PriorityQueue implements heap.Interface and holds Edges

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type WaterMinHeap

type WaterMinHeap [][3]int

MinHeap is a min-heap of [3]int arrays.

func (WaterMinHeap) Len

func (h WaterMinHeap) Len() int

func (WaterMinHeap) Less

func (h WaterMinHeap) Less(i, j int) bool

func (*WaterMinHeap) Pop

func (h *WaterMinHeap) Pop() interface{}

func (*WaterMinHeap) Push

func (h *WaterMinHeap) Push(x interface{})

func (WaterMinHeap) Swap

func (h WaterMinHeap) Swap(i, j int)

Jump to

Keyboard shortcuts

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