이 쿼리는 네트워크에서 지배적 인 세트를 가져옵니다. 그래서 예를 들어 네트워크에게 주어진이 쿼리에서 'ORA-01489 : 문자열 연결 결과가 너무 깁니다.'를 어떻게 제거 할 수 있습니까?
A<----->B
B<----->C
B<----->D
C<----->E
D<----->C
D<----->E
F<----->E
는, E
B
B, F
A, E
를 반환하지만 내가 문자열 방법을 사용하고 있기 때문에 대량의 데이터가 작동하지 않습니다 내 결과에. 내가 문자열 방법을 제거하고 용량이 큰 복잡한 쿼리 처리 복잡한 문자열을하고 싶지 않아 내 경험에 아무 소용이
With t as (select 'A' as per1, 'B' as per2 from dual union all
select 'B','C' from dual union all
select 'B','D' from dual union all
select 'C','B' from dual union all
select 'C','E' from dual union all
select 'D','C' from dual union all
select 'D','E' from dual union all
select 'E','C' from dual union all
select 'E','D' from dual union all
select 'F','E' from dual)
,t2 as (select distinct least(per1, per2) as per1, greatest(per1, per2) as per2 from t union
select distinct greatest(per1, per2) as per1, least(per1, per2) as per1 from t)
,t3 as (select per1, per2, row_number() over (partition by per1 order by per2) as rn from t2)
,people as (select per, row_number() over (order by per) rn
from (select distinct per1 as per from t union
select distinct per2 from t)
)
,comb as (select sys_connect_by_path(per,',')||',' as p
from people
connect by rn > prior rn
)
,find as (select p, per2, count(*) over (partition by p) as cnt
from (
select distinct comb.p, t3.per2
from comb, t3
where instr(comb.p, ','||t3.per1||',') > 0 or instr(comb.p, ','||t3.per2||',') > 0
)
)
,rnk as (select p, rank() over (order by length(p)) as rnk
from find
where cnt = (select count(*) from people)
order by rnk
) select distinct trim(',' from p) as p from rnk where rnk.rnk = 1`
위의 데이터 A <---> B, B <---> C ....가 기본 데이터입니다. 그들은 사용자 및 친구 관계의 한 형태를 나타냅니다. 나는이 주어진 네트워크 최소한의 지배 세트에서 설정 한 최소한의 지배를 찾기 위해 노력하고는 소셜 네트워크에서 집합 더 많은 정보를 원하시면 여기 설정에 주도권의 네트워크에있는 모든 사람과 친구가 사람들의 세트입니다 : http : //en.wikipedia.org/wiki/Dominating_set –