AABB
AlignmentBehavior
ArriveBehavior
AStar
BFS
BoundingSphere
BVH
BVHNode
Cell
CellSpacePartitioning
CohesionBehavior
CompositeGoal
ConvexHull
Corridor
CostTable
DFS
Dijkstra
Edge
EntityManager
EvadeBehavior
EventDispatcher
Behavior
FollowPathBehavior
FuzzyAND
FuzzyCompositeTerm
FuzzyFAIRLY
FuzzyModule
FuzzyOR
FuzzyRule
FuzzySet
FuzzyTerm
FuzzyVariable
FuzzyVERY
GameEntity
Goal
GoalEvaluator
Graph
GraphUtils
HalfEdge
HeuristicPolicyDijkstra
HeuristicPolicyEuclid
HeuristicPolicyEuclidSquared
HeuristicPolicyManhattan
InterposeBehavior
LeftSCurveFuzzySet
LeftShoulderFuzzySet
LineSegment
Logger
MathUtils
Matrix3
Matrix4
MemoryRecord
MemorySystem
MeshGeometry
MessageDispatcher
MovingEntity
NavEdge
NavMesh
NavMeshLoader
NavNode
Node
NormalDistFuzzySet
OBB
ObstacleAvoidanceBehavior
OffsetPursuitBehavior
OnPathBehavior
Path
Plane
Polygon
Polyhedron
PriorityQueue
PursuitBehavior
Quaternion
Ray
RectangleTriggerRegion
Regular
RightSCurveFuzzySet
RightShoulderFuzzySet
SAT
SeekBehavior
SeparationBehavior
SingletonFuzzySet
Smoother
SphericalTriggerRegion
State
StateMachine
SteeringBehavior
SteeringManager
Task
TaskQueue
Telegram
Think
Time
TriangularFuzzySet
Trigger
TriggerRegion
Vector3
Vehicle
Version
WanderBehavior

removeEdge

功能描述

removeEdge 方法从 Graph 对象中移除一条边。

语法

Graph.removeEdge(fromNode, toNode)

参数

  • fromNode: 表示边的起始节点的名称。
  • toNode: 表示边的结束节点的名称。

返回值

该方法没有返回值。

异常

  • 若输入的 fromNodetoNode 不存在于 Graph 对象中,则抛出异常。

示例

const graph = new Graph();

graph.addNode("A");
graph.addNode("B");
graph.addEdge("A", "B");

console.log(graph.edges); // {"A": ["B"], "B": ["A"]}

graph.removeEdge("A", "B");

console.log(graph.edges); // {"A": [], "B": []}

实现原理

removeEdge 方法中,先判断输入的起始节点和结束节点是否存在于 Graph 对象中,若不存在则抛出异常。若存在则遍历该边所连接的两个节点,分别将它们之间的对应关系从 Graph 对象中删除。

注意事项

  • removeEdge 方法只能移除无向图中的边,不能移除有向图中的边,需要考虑到图的类型。