If you send the VERSION command to a server it replys with a bunch of key=value pairs, one of these may be NETWORK= wich contains the unique network name.
If you keep a list of all unique network names you could then compare a new servers NETWORK with the ones you've already got, and thus check if you're already connected to this network.
EDIT:
Not all networks send this key tho...
Freenode for example does so:
[14:15] == ircd-seven-1.1.3(20111112-b71671d1e846,charybdis-3.4-dev). herbert.freenode.net eHIKMpSZ6 TS6ow 43U
[14:15] == CHANTYPES=# EXCEPTS INVEX CHANMODES=eIbq,k,flj,CFLMPQScgimnprstz CHANLIMIT=#:120 PREFIX=(ov)@+ MAXLIST=bqeI:100 MODES=4 NETWORK=freenode KNOCK STATUSMSG=@+ CALLERID=g are supported by this server
[14:15] == CASEMAPPING=rfc1459 CHARSET=ascii NICKLEN=16 CHANNELLEN=50 TOPICLEN=390 ETRACE CPRIVMSG CNOTICE DEAF=D MONITOR=100 FNC TARGMAX=NAMES:1,LIST:1,KICK:1,WHOIS:1,PRIVMSG:4,NOTICE:4,ACCEPT:,MONITOR: are supported by this server
[14:15] == EXTBAN=$,ajrxz WHOX CLIENTVER=3.0 SAFELIST ELIST=CTU are supported by this server
Evilzone doesn't send the NETWORK key=value pair:
14:24 ** Fhin6XeOoZEM3 [*=2311] **
14:25 ** 25 MAXLIST=b:60,e:60,I:60 NICKLEN=30 CHANNELLEN=32 TOPICLEN=307 KICKLEN=307 AWAYLEN=307 :are supported by this server **
14:25 ** are supported by this server **
14:25 ** are supported by this server **