-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathis_disjoint.c
29 lines (26 loc) · 1.27 KB
/
is_disjoint.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* is_disjoint.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mihykim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/17 00:05:56 by mihykim #+# #+# */
/* Updated: 2020/04/23 14:06:57 by mihykim ### ########.fr */
/* */
/* ************************************************************************** */
#include "union_find.h"
bool is_disjoint(t_node *node1, t_node *node2)
{
if (node1 == NULL || node2 == NULL)
return (true);
if (find(node1) == find(node2))
return (false);
return (true);
}
/*
** line 18 : Changed from 'false' to true,
** since every set is disjoint from the empty set.
** line 19 : Changed from 'node1->parent == node2->parent'
** to 'find(node1) == find(node2)'
*/