PedestrainCounting
Public Member Functions | List of all members
UnionFind Class Reference

#include <UnionFind.h>

Public Member Functions

 UnionFind (int N)
 
int GetCount () const
 
int GetSize (int root)
 
int Find (int p) const
 
bool Connected (int p, int q) const
 
void Union (int p, int q)
 

Detailed Description

A weighted union find with path compression.

Author
Zhengrong Wang

Member Function Documentation

bool UnionFind::Connected ( int  p,
int  q 
) const
inline

Are the two sites p and q in the same component?

Parameters
pthe integer representing one site
qthe integer representing the other site
Returns
true if the two sites p and q are in the same component, and false otherwise
Exceptions
java.lang.IndexOutOfBoundsExceptionunless both 0 <= p < N and 0 <= q < N
int UnionFind::Find ( int  p) const

Returns the component identifier for the component containing site p.

Parameters
pthe integer representing one site
Returns
the component identifier for the component containing site p
Exceptions
java.lang.IndexOutOfBoundsExceptionunless 0 <= p < N
int UnionFind::GetCount ( ) const
inline

Returns the number of components.

Returns
the number of components (between 1 and N)
int UnionFind::GetSize ( int  root)
inline

Returns the size of this components.

Returns
the size of this components (between 1 and N)
void UnionFind::Union ( int  p,
int  q 
)

Merges the component containing sitep with the component containing site q.

Parameters
pthe integer representing one site
qthe integer representing the other site
Exceptions
java.lang.IndexOutOfBoundsExceptionunless both 0 <= p < N and 0 <= q < N

The documentation for this class was generated from the following files: