Comparing morphisms of algebraic structures and topology Let $X$ and $Y$ be groups, it seems natural to me that a proper function (homomorphism) $\phi$  from $X$ to $Y$ has this property that $\phi \subset X \times Y$ is a subgroup. Is there a way to define continuous functions similarly?
 A: If you restrict to compact Hausdorff spaces, this works out very nicely.  First, note that if $X$ is a compact Hausdorff space, a "sub-compact Hausdorff space" of $X$ is a closed subspace of $X$ (closed since it needs to be compact; note also that these correspond to monomorphisms in the sense of category theory).  Then the following is true: a function $\phi:X\to Y$ between compact Hausdorff spaces is continuous iff its graph $\Gamma\subseteq X\times Y$ is closed (i.e., iff its graph is a sub-compact Hausdorff space).
To prove this, first suppose $\phi$ is continuous.  Then $\Gamma$ is the image of a continuous map $X\to X\times Y$ (namely, $x\mapsto(x,\phi(x))$), and so is compact since $X$ is compact, and hence is closed since $X\times Y$ is Hausdorff.  Conversely, if $\Gamma$ is closed, then it is compact, so the projection $\Gamma\to X$ must be a homeomorphism, since it is a continuous bijection from a compact space to a Hausdorff space.  Since $\phi$ is the composition of the inverse of this bijection with the projection $\Gamma\to Y$, it follows that $\phi$ is continuous.
Note that this breaks down for general spaces.  For instance, if $X=Y$ is not Hausdorff, then the identity map $X\to X$ is continuous, but its graph is not closed (the diagonal in $X\times X$ is closed iff $X$ is Hausdorff).  And if $Y$ is discrete and $X$ is $T_1$, then any injection $X\to Y$ has closed graph, but such an injection is not continuous unless $X$ is also discrete.  In general, as Captain Lama's answer discusses, you need to directly require that the projection $\Gamma\to X$ is a homeomorphism, which cannot be translated into saying $\Gamma$ is some special kind of subspace of $X\times Y$ without reference to the projection maps.
Much more generally, if you have any monad $T$ on the category of sets and $X$ and $Y$ are $T$-algebras, a function $\phi:X\to Y$ between the underlying sets is a homomorphism iff its graph is a subalgebra of $X\times Y$ (the proof is straightforward once you write down what all the words actually mean).  It is a nontrivial theorem that the category of compact Hausdorff spaces can be considered as the algebras over a monad on sets, and the characterization of continuity for compact Hausdorff spaces given above follows.
For some related discussion, you may be interested in this answer of mine on MathOverflow, which explores these ideas in the context of defining what it would mean for a multivalued function (i.e., a relation) to be continuous.
A: The thing is, you can't take any subgroup $G\subset X\times Y$. It has to satisfy that the first projection gives an isomorphism $G\to X$. In the category of groups, being an isomorphism is the same as being bijective, so you can sort of define morphisms that way just knowing about functions.
But for topological spaces, the graph of a continuous function $X\to Y$ has to satisfy that the first projection is a homeomorphism. So if you want to define continuous functions that way, you have to know about products, subspaces and homeomorphisms.
But yes, if you know about these, you can define a continuous function as a subspace of the product such that the fist projection induces a homeomorphism, since then from $\Gamma_f\subset X\times Y$ you have $f(x) = \pi_2(\pi_1^{-1}(x))$ continuous where $\pi_i$ are the two projections $X\times Y\to X,Y$, and $\pi_1^{-1}:X\to \Gamma_f$ is the inverse of $\pi_1:\Gamma_f\to X$.
