Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def organizations_store_clustering(organizations_store: Dict[int, Set[str]],
- position_clusters: List[Set[int]],
- organization_clusters: List[Set[str]]) -> Tuple[List[Set[int]], List[Set[str]]]:
- position_clusters: List[Set[int]] = []
- organization_clusters: List[Set[str]] = []
- for position, entry in organizations_store.items():
- entry: Set[str] = set(entry)
- if len(entry) == 0:
- create_cluster(position, entry, position_clusters, organization_clusters)
- continue
- if len(position_clusters) == 0:
- create_cluster(position, entry, position_clusters, organization_clusters)
- continue
- else:
- is_intersected = False
- for position_cluster, organization_cluster in zip(position_clusters, organization_clusters):
- if len(organization_cluster) > 0:
- if entry.issubset(organization_cluster):
- is_intersected = True
- position_cluster.add(position)
- organization_cluster.update(entry)
- print(f'{position_cluster} {organization_cluster} updated')
- break
- if not is_intersected:
- create_cluster(position, entry, position_clusters, organization_clusters)
- return position_clusters, organization_clusters
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement