Is there any analogy between homotopy of spaces and homotopy between maps? I am a beginner of Algebraic topology course. I just come across the definition of Homotopy
Homotopy of 2 maps: 
$f,g:S\to T$ are 2 continuous maps is said to called homotopic if there exist continuous map $H:S\times [0,1]\to T$ such that $H(s,0)=f(s)$ and $H(s,1)=g(s)$.
Homotopy of 2 spaces : 
Two topological spaces $X,Y$ are said to homotopic if there is continous map $f:S\to T$ and $g:T\to S$ such that $f\circ g:T\to T$ is homotopic to Identity on T and $g\circ f:S\to S$ is homotopic to Identity on S.
I know that to define second definition we used the first one.Also intuitively for the first defination, if we consider graphs of 2 function then one continuously deformed to another 
Is this continuous deformation happen in 2nd definition .But how to interpret that from definition only?
This question arises when I am reading and try to relate both definition
Please Help me 
 A: You have mentioned graphs of functions: indeed it is quite clear that if $f\sim g$ then the graph of $f$ $\subset S\times T$ is homotopy equivalent to the one of $g$, however the converse is far from true, as any two graphs are homotopy equivalent. In fact, any two graphs are homeomorphic : let $f:S\to T$ be any continuous map and $\Gamma_f = \{(s,t)\in S\times T, s\in S, f(s) =t\}$. Then we have a map $i:S\to \Gamma_f, s\mapsto (s,f(s))$ and a map $\Gamma_f \to S, (s,t)\mapsto s$ which are both clearly continuous, and inverse to one another. 
I'm not sure this answers your question, but there's a way to redefine "homotopic maps" in terms of "homotopy equivalence of spaces" if you assume that this second notion is known. 
Then we have the following : given a space $S$, a cylinder for $S$ is a space $S_{\wedge I}$ together with maps $in_0, in_1 : S\to S_{\wedge I}$ and a homotopy equivalence $p:S_{\wedge I}\to S$ such that $p\circ in_0 = id_S, p\circ in_1 = id_S$. 
Then, two maps $f,g: S\to T$ are homotopy equivalent if and only if there is a cylinder for $S$, $(S_{\wedge I},in_0,in_1,p)$ and a map $H:S_{\wedge I}\to T$ such that $H \circ in_0 = f, H\circ in_1 = g$. 
It's quite easy to prove : in one direction, if they're homotopic in the usual definition, then you may take $S_{\wedge I} = S\times I$ where $I=[0,1]$, $in_i (s)= (s,i)$ and $p(s,t) = s$ and then the usual homotopy $H$ works as an $H$. 
Conversely, if $f,g$ are homotopic in this definition, then as $p$ is a homotopy equivalence, we get from $p\circ in_0 = p\circ in_1$ that $in_0\sim in_1$ so $H\circ in_0\sim H\circ in_1$ so $f\sim g$ : $f$ and $g$ are homotopic in the usual definition. 
