//	reducible2.c
//	JR 5/22/96
//	Check for case of reducibility missed by B&H.

//	5/22/96	Started.

Boolean Homeo::reducibleType2()
{
	Set<Name> S=theNameManager.periphery();
	Set<Name> nonP=theNameManager.edges();
	nonP-=S;


//	Find the periperal edges that appear in the images
//	of the non-peripheral edges.
	
	Set<Name> toGo;
	SetBrowser<MapElement> k(theMap);
	for(k.init();k.ok();k.advance())
	{
		MapElement m(k.current());
		if(!S.has(m.source().name()))
		{
			LinListBrowser<DE> j(m.image());
			for(j.init();j.ok();++j)
			{
				if(S.has(j.ahead().name())) 
				{
					toGo.add( j.ahead().name() );
				}
			}
		}
	}

//	Remove from S edges that have pre-images intersecting nonP.

	S -= toGo;


// Find out if there is a forward-invariant component of S. 
// (Since S is a subset of P, and g|P is simplicial,
//  forward-invariant <=> backward-invariant. )

	SetBrowser<Name> i(S);
	for(i.init();i.ok();)
	{
		Name n=i.current();
		if( !S.has( theMap.derivative(DE(n,0)).name() ) )
		{
			S.remove(n);
			i.init();
		}
		else
		{
			i.advance();
		}
	}
		
cout << "    Invariant component of P: " << S << endl;
	if( !S.isEmpty() ) 	return 1;
	else			return 0;
	

}
